From c2c446ad29437bb92b157423c632286608ebd3ec Mon Sep 17 00:00:00 2001 From: Robert Foss Date: Fri, 19 May 2017 16:50:17 -0400 Subject: drm: Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ to UAPI Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ defines to the UAPI as a convenience. Ideally the DRM_ROTATE_ and DRM_REFLECT_ property ids are looked up through the atomic API, but realizing that userspace is likely to take shortcuts and assume that the enum values are what is sent over the wire. As a result these defines are provided purely as a convenience to userspace applications. Changes since v3: - Switched away from past tense in comments - Add define name change to previously mis-spelled DRM_REFLECT_X comment - Improved the comment for the DRM_MODE_REFLECT_ comment Changes since v2: - Changed define prefix from DRM_MODE_PROP_ to DRM_MODE_ - Fix compilation errors - Changed comment formatting - Deduplicated comment lines - Clarified DRM_MODE_PROP_REFLECT_ comment Changes since v1: - Moved defines from drm.h to drm_mode.h - Changed define prefix from DRM_ to DRM_MODE_PROP_ - Updated uses of the defines to the new prefix - Removed include from drm_rect.c - Stopped using the BIT() macro Signed-off-by: Robert Foss Reviewed-by: Emil Velikov Reviewed-by: Sinclair Yeh Acked-by: Liviu Dudau Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/20170519205017.23307-2-robert.foss@collabora.com --- drivers/gpu/drm/omapdrm/omap_fb.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 29dc677dd4d3..5ca0537bb427 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -167,30 +167,30 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, uint32_t w = win->src_w; uint32_t h = win->src_h; - switch (win->rotation & DRM_ROTATE_MASK) { + switch (win->rotation & DRM_MODE_ROTATE_MASK) { default: dev_err(fb->dev->dev, "invalid rotation: %02x", (uint32_t)win->rotation); /* fallthru to default to no rotation */ case 0: - case DRM_ROTATE_0: + case DRM_MODE_ROTATE_0: orient = 0; break; - case DRM_ROTATE_90: + case DRM_MODE_ROTATE_90: orient = MASK_XY_FLIP | MASK_X_INVERT; break; - case DRM_ROTATE_180: + case DRM_MODE_ROTATE_180: orient = MASK_X_INVERT | MASK_Y_INVERT; break; - case DRM_ROTATE_270: + case DRM_MODE_ROTATE_270: orient = MASK_XY_FLIP | MASK_Y_INVERT; break; } - if (win->rotation & DRM_REFLECT_X) + if (win->rotation & DRM_MODE_REFLECT_X) orient ^= MASK_X_INVERT; - if (win->rotation & DRM_REFLECT_Y) + if (win->rotation & DRM_MODE_REFLECT_Y) orient ^= MASK_Y_INVERT; /* adjust x,y offset for flip/invert: */ @@ -205,9 +205,9 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, info->rotation_type = OMAP_DSS_ROT_TILER; info->screen_width = omap_gem_tiled_stride(plane->bo, orient); } else { - switch (win->rotation & DRM_ROTATE_MASK) { + switch (win->rotation & DRM_MODE_ROTATE_MASK) { case 0: - case DRM_ROTATE_0: + case DRM_MODE_ROTATE_0: /* OK */ break; -- cgit v1.2.3 From aa0408bcb1b8c2c5941b6e0e7ce0ad2b733bb971 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 21 Apr 2017 00:33:50 +0300 Subject: drm: omapdrm: Remove remap argument to omap_gem_get_paddr() The function is always called with the remap argument set to true. Hardcode that behaviour and remove it. Signed-off-by: Laurent Pinchart Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/omap_drv.h | 3 +-- drivers/gpu/drm/omapdrm/omap_fb.c | 2 +- drivers/gpu/drm/omapdrm/omap_fbdev.c | 2 +- drivers/gpu/drm/omapdrm/omap_gem.c | 10 ++++------ drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 2 +- 5 files changed, 8 insertions(+), 11 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index 16aa43c6fbc2..2b5e61b7efdf 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -188,8 +188,7 @@ int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll); void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff); void omap_gem_dma_sync(struct drm_gem_object *obj, enum dma_data_direction dir); -int omap_gem_get_paddr(struct drm_gem_object *obj, - dma_addr_t *paddr, bool remap); +int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *paddr); void omap_gem_put_paddr(struct drm_gem_object *obj); int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages, bool remap); diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 5ca0537bb427..5fc240f3a67e 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -258,7 +258,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb) for (i = 0; i < n; i++) { struct plane *plane = &omap_fb->planes[i]; - ret = omap_gem_get_paddr(plane->bo, &plane->paddr, true); + ret = omap_gem_get_paddr(plane->bo, &plane->paddr); if (ret) goto fail; omap_gem_dma_sync(plane->bo, DMA_TO_DEVICE); diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c index 4e89dd537862..d738e5b3ae45 100644 --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c @@ -162,7 +162,7 @@ static int omap_fbdev_create(struct drm_fb_helper *helper, * to it). Then we just need to be sure that we are able to re- * pin it in case of an opps. */ - ret = omap_gem_get_paddr(fbdev->bo, &paddr, true); + ret = omap_gem_get_paddr(fbdev->bo, &paddr); if (ret) { dev_err(dev->dev, "could not map (paddr)! Skipping framebuffer alloc\n"); diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 4bb52a5f5939..3d94ea8684e6 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -784,12 +784,10 @@ void omap_gem_dma_sync(struct drm_gem_object *obj, } } -/* Get physical address for DMA.. if 'remap' is true, and the buffer is not - * already contiguous, remap it to pin in physically contiguous memory.. (ie. - * map in TILER) +/* Get physical address for DMA.. if the buffer is not already contiguous, remap + * it to pin in physically contiguous memory.. (ie. map in TILER) */ -int omap_gem_get_paddr(struct drm_gem_object *obj, - dma_addr_t *paddr, bool remap) +int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *paddr) { struct omap_drm_private *priv = obj->dev->dev_private; struct omap_gem_object *omap_obj = to_omap_bo(obj); @@ -797,7 +795,7 @@ int omap_gem_get_paddr(struct drm_gem_object *obj, mutex_lock(&obj->dev->struct_mutex); - if (!is_contiguous(omap_obj) && remap && priv->has_dmm) { + if (!is_contiguous(omap_obj) && priv->has_dmm) { if (omap_obj->paddr_cnt == 0) { struct page **pages; uint32_t npages = obj->size >> PAGE_SHIFT; diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c index 0dbe0306953d..024cf27d74db 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c @@ -41,7 +41,7 @@ static struct sg_table *omap_gem_map_dma_buf( /* camera, etc, need physically contiguous.. but we need a * better way to know this.. */ - ret = omap_gem_get_paddr(obj, &paddr, true); + ret = omap_gem_get_paddr(obj, &paddr); if (ret) goto out; -- cgit v1.2.3 From 16869083b9bec8c1090442bd176a5b376708aba0 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 21 Apr 2017 00:33:51 +0300 Subject: drm: omapdrm: Rename occurrences of paddr to dma_addr The fields, variables and functions deal with DMA addresses, name them accordingly. The omap_gem_get_paddr() and omap_gem_put_paddr() will be addressed differently separately. Signed-off-by: Laurent Pinchart Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/omap_drv.h | 6 +-- drivers/gpu/drm/omapdrm/omap_fb.c | 21 +++++----- drivers/gpu/drm/omapdrm/omap_fbdev.c | 8 ++-- drivers/gpu/drm/omapdrm/omap_gem.c | 70 +++++++++++++++---------------- drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 8 ++-- 5 files changed, 57 insertions(+), 56 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index 2b5e61b7efdf..ef5001f1f5c8 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -188,14 +188,14 @@ int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll); void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff); void omap_gem_dma_sync(struct drm_gem_object *obj, enum dma_data_direction dir); -int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *paddr); +int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *dma_addr); void omap_gem_put_paddr(struct drm_gem_object *obj); int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages, bool remap); int omap_gem_put_pages(struct drm_gem_object *obj); uint32_t omap_gem_flags(struct drm_gem_object *obj); -int omap_gem_rotated_paddr(struct drm_gem_object *obj, uint32_t orient, - int x, int y, dma_addr_t *paddr); +int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient, + int x, int y, dma_addr_t *dma_addr); uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj); size_t omap_gem_mmap_size(struct drm_gem_object *obj); int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient); diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 5fc240f3a67e..444bf92c5252 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -74,7 +74,7 @@ struct plane { struct drm_gem_object *bo; uint32_t pitch; uint32_t offset; - dma_addr_t paddr; + dma_addr_t dma_addr; }; #define to_omap_framebuffer(x) container_of(x, struct omap_framebuffer, base) @@ -85,7 +85,7 @@ struct omap_framebuffer { const struct drm_format_info *format; enum omap_color_mode dss_format; struct plane planes[2]; - /* lock for pinning (pin_count and planes.paddr) */ + /* lock for pinning (pin_count and planes.dma_addr) */ struct mutex lock; }; @@ -130,7 +130,7 @@ static uint32_t get_linear_addr(struct plane *plane, + (x * format->cpp[n] / (n == 0 ? 1 : format->hsub)) + (y * plane->pitch / (n == 0 ? 1 : format->vsub)); - return plane->paddr + offset; + return plane->dma_addr + offset; } bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb) @@ -201,7 +201,8 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, if (orient & MASK_X_INVERT) x += w - 1; - omap_gem_rotated_paddr(plane->bo, orient, x, y, &info->paddr); + omap_gem_rotated_dma_addr(plane->bo, orient, x, y, + &info->paddr); info->rotation_type = OMAP_DSS_ROT_TILER; info->screen_width = omap_gem_tiled_stride(plane->bo, orient); } else { @@ -232,8 +233,8 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, if (info->rotation_type == OMAP_DSS_ROT_TILER) { WARN_ON(!(omap_gem_flags(plane->bo) & OMAP_BO_TILED)); - omap_gem_rotated_paddr(plane->bo, orient, - x/2, y/2, &info->p_uv_addr); + omap_gem_rotated_dma_addr(plane->bo, orient, x/2, y/2, + &info->p_uv_addr); } else { info->p_uv_addr = get_linear_addr(plane, format, 1, x, y); } @@ -258,7 +259,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb) for (i = 0; i < n; i++) { struct plane *plane = &omap_fb->planes[i]; - ret = omap_gem_get_paddr(plane->bo, &plane->paddr); + ret = omap_gem_get_paddr(plane->bo, &plane->dma_addr); if (ret) goto fail; omap_gem_dma_sync(plane->bo, DMA_TO_DEVICE); @@ -274,7 +275,7 @@ fail: for (i--; i >= 0; i--) { struct plane *plane = &omap_fb->planes[i]; omap_gem_put_paddr(plane->bo); - plane->paddr = 0; + plane->dma_addr = 0; } mutex_unlock(&omap_fb->lock); @@ -300,7 +301,7 @@ void omap_framebuffer_unpin(struct drm_framebuffer *fb) for (i = 0; i < n; i++) { struct plane *plane = &omap_fb->planes[i]; omap_gem_put_paddr(plane->bo); - plane->paddr = 0; + plane->dma_addr = 0; } mutex_unlock(&omap_fb->lock); @@ -458,7 +459,7 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, plane->bo = bos[i]; plane->offset = mode_cmd->offsets[i]; plane->pitch = pitch; - plane->paddr = 0; + plane->dma_addr = 0; } drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd); diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c index d738e5b3ae45..dabb1affa2ca 100644 --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c @@ -106,7 +106,7 @@ static int omap_fbdev_create(struct drm_fb_helper *helper, union omap_gem_size gsize; struct fb_info *fbi = NULL; struct drm_mode_fb_cmd2 mode_cmd = {0}; - dma_addr_t paddr; + dma_addr_t dma_addr; int ret; sizes->surface_bpp = 32; @@ -162,7 +162,7 @@ static int omap_fbdev_create(struct drm_fb_helper *helper, * to it). Then we just need to be sure that we are able to re- * pin it in case of an opps. */ - ret = omap_gem_get_paddr(fbdev->bo, &paddr); + ret = omap_gem_get_paddr(fbdev->bo, &dma_addr); if (ret) { dev_err(dev->dev, "could not map (paddr)! Skipping framebuffer alloc\n"); @@ -193,11 +193,11 @@ static int omap_fbdev_create(struct drm_fb_helper *helper, drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth); drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height); - dev->mode_config.fb_base = paddr; + dev->mode_config.fb_base = dma_addr; fbi->screen_base = omap_gem_vaddr(fbdev->bo); fbi->screen_size = fbdev->bo->size; - fbi->fix.smem_start = paddr; + fbi->fix.smem_start = dma_addr; fbi->fix.smem_len = fbdev->bo->size; /* if we have DMM, then we can use it for scrolling by just diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 3d94ea8684e6..038a05918002 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -50,7 +50,7 @@ struct omap_gem_object { uint32_t roll; /** - * paddr contains the buffer DMA address. It is valid for + * dma_addr contains the buffer DMA address. It is valid for * * - buffers allocated through the DMA mapping API (with the * OMAP_BO_MEM_DMA_API flag set) @@ -58,24 +58,24 @@ struct omap_gem_object { * - buffers imported from dmabuf (with the OMAP_BO_MEM_DMABUF flag set) * if they are physically contiguous (when sgt->orig_nents == 1) * - * - buffers mapped through the TILER when paddr_cnt is not zero, in + * - buffers mapped through the TILER when dma_addr_cnt is not zero, in * which case the DMA address points to the TILER aperture * * Physically contiguous buffers have their DMA address equal to the * physical address as we don't remap those buffers through the TILER. * * Buffers mapped to the TILER have their DMA address pointing to the - * TILER aperture. As TILER mappings are refcounted (through paddr_cnt) - * the DMA address must be accessed through omap_get_get_paddr() to - * ensure that the mapping won't disappear unexpectedly. References must - * be released with omap_gem_put_paddr(). + * TILER aperture. As TILER mappings are refcounted (through + * dma_addr_cnt) the DMA address must be accessed through + * omap_get_get_paddr() to ensure that the mapping won't disappear + * unexpectedly. References must be released with omap_gem_put_paddr(). */ - dma_addr_t paddr; + dma_addr_t dma_addr; /** - * # of users of paddr + * # of users of dma_addr */ - uint32_t paddr_cnt; + uint32_t dma_addr_cnt; /** * If the buffer has been imported from a dmabuf the OMAP_DB_DMABUF flag @@ -119,7 +119,7 @@ struct omap_gem_object { #define NUM_USERGART_ENTRIES 2 struct omap_drm_usergart_entry { struct tiler_block *block; /* the reserved tiler block */ - dma_addr_t paddr; + dma_addr_t dma_addr; struct drm_gem_object *obj; /* the current pinned obj */ pgoff_t obj_pgoff; /* page offset of obj currently mapped in */ @@ -392,7 +392,7 @@ static int fault_1d(struct drm_gem_object *obj, pfn = page_to_pfn(omap_obj->pages[pgoff]); } else { BUG_ON(!is_contiguous(omap_obj)); - pfn = (omap_obj->paddr >> PAGE_SHIFT) + pgoff; + pfn = (omap_obj->dma_addr >> PAGE_SHIFT) + pgoff; } VERB("Inserting %p pfn %lx, pa %lx", (void *)vmf->address, @@ -485,7 +485,7 @@ static int fault_2d(struct drm_gem_object *obj, return ret; } - pfn = entry->paddr >> PAGE_SHIFT; + pfn = entry->dma_addr >> PAGE_SHIFT; VERB("Inserting %p pfn %lx, pa %lx", (void *)vmf->address, pfn, pfn << PAGE_SHIFT); @@ -787,7 +787,7 @@ void omap_gem_dma_sync(struct drm_gem_object *obj, /* Get physical address for DMA.. if the buffer is not already contiguous, remap * it to pin in physically contiguous memory.. (ie. map in TILER) */ -int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *paddr) +int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *dma_addr) { struct omap_drm_private *priv = obj->dev->dev_private; struct omap_gem_object *omap_obj = to_omap_bo(obj); @@ -796,7 +796,7 @@ int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *paddr) mutex_lock(&obj->dev->struct_mutex); if (!is_contiguous(omap_obj) && priv->has_dmm) { - if (omap_obj->paddr_cnt == 0) { + if (omap_obj->dma_addr_cnt == 0) { struct page **pages; uint32_t npages = obj->size >> PAGE_SHIFT; enum tiler_fmt fmt = gem2fmt(omap_obj->flags); @@ -833,17 +833,17 @@ int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *paddr) goto fail; } - omap_obj->paddr = tiler_ssptr(block); + omap_obj->dma_addr = tiler_ssptr(block); omap_obj->block = block; - DBG("got paddr: %pad", &omap_obj->paddr); + DBG("got dma address: %pad", &omap_obj->dma_addr); } - omap_obj->paddr_cnt++; + omap_obj->dma_addr_cnt++; - *paddr = omap_obj->paddr; + *dma_addr = omap_obj->dma_addr; } else if (is_contiguous(omap_obj)) { - *paddr = omap_obj->paddr; + *dma_addr = omap_obj->dma_addr; } else { ret = -EINVAL; goto fail; @@ -864,9 +864,9 @@ void omap_gem_put_paddr(struct drm_gem_object *obj) int ret; mutex_lock(&obj->dev->struct_mutex); - if (omap_obj->paddr_cnt > 0) { - omap_obj->paddr_cnt--; - if (omap_obj->paddr_cnt == 0) { + if (omap_obj->dma_addr_cnt > 0) { + omap_obj->dma_addr_cnt--; + if (omap_obj->dma_addr_cnt == 0) { ret = tiler_unpin(omap_obj->block); if (ret) { dev_err(obj->dev->dev, @@ -877,7 +877,7 @@ void omap_gem_put_paddr(struct drm_gem_object *obj) dev_err(obj->dev->dev, "could not release unmap: %d\n", ret); } - omap_obj->paddr = 0; + omap_obj->dma_addr = 0; omap_obj->block = NULL; } } @@ -889,16 +889,16 @@ void omap_gem_put_paddr(struct drm_gem_object *obj) * specified orientation and x,y offset from top-left corner of buffer * (only valid for tiled 2d buffers) */ -int omap_gem_rotated_paddr(struct drm_gem_object *obj, uint32_t orient, - int x, int y, dma_addr_t *paddr) +int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient, + int x, int y, dma_addr_t *dma_addr) { struct omap_gem_object *omap_obj = to_omap_bo(obj); int ret = -EINVAL; mutex_lock(&obj->dev->struct_mutex); - if ((omap_obj->paddr_cnt > 0) && omap_obj->block && + if ((omap_obj->dma_addr_cnt > 0) && omap_obj->block && (omap_obj->flags & OMAP_BO_TILED)) { - *paddr = tiler_tsptr(omap_obj->block, orient, x, y); + *dma_addr = tiler_tsptr(omap_obj->block, orient, x, y); ret = 0; } mutex_unlock(&obj->dev->struct_mutex); @@ -1019,7 +1019,7 @@ void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m) seq_printf(m, "%08x: %2d (%2d) %08llx %pad (%2d) %p %4d", omap_obj->flags, obj->name, kref_read(&obj->refcount), - off, &omap_obj->paddr, omap_obj->paddr_cnt, + off, &omap_obj->dma_addr, omap_obj->dma_addr_cnt, omap_obj->vaddr, omap_obj->roll); if (omap_obj->flags & OMAP_BO_TILED) { @@ -1076,7 +1076,7 @@ void omap_gem_free_object(struct drm_gem_object *obj) /* this means the object is still pinned.. which really should * not happen. I think.. */ - WARN_ON(omap_obj->paddr_cnt > 0); + WARN_ON(omap_obj->dma_addr_cnt > 0); if (omap_obj->pages) { if (omap_obj->flags & OMAP_BO_MEM_DMABUF) @@ -1087,7 +1087,7 @@ void omap_gem_free_object(struct drm_gem_object *obj) if (omap_obj->flags & OMAP_BO_MEM_DMA_API) { dma_free_wc(dev->dev, obj->size, omap_obj->vaddr, - omap_obj->paddr); + omap_obj->dma_addr); } else if (omap_obj->vaddr) { vunmap(omap_obj->vaddr); } else if (obj->import_attach) { @@ -1184,7 +1184,7 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, /* Allocate memory if needed. */ if (flags & OMAP_BO_MEM_DMA_API) { omap_obj->vaddr = dma_alloc_wc(dev->dev, size, - &omap_obj->paddr, + &omap_obj->dma_addr, GFP_KERNEL); if (!omap_obj->vaddr) goto err_release; @@ -1228,7 +1228,7 @@ struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size, omap_obj->sgt = sgt; if (sgt->orig_nents == 1) { - omap_obj->paddr = sg_dma_address(sgt->sgl); + omap_obj->dma_addr = sg_dma_address(sgt->sgl); } else { /* Create pages list from sgt */ struct sg_page_iter iter; @@ -1335,11 +1335,11 @@ void omap_gem_init(struct drm_device *dev) i, j, PTR_ERR(block)); return; } - entry->paddr = tiler_ssptr(block); + entry->dma_addr = tiler_ssptr(block); entry->block = block; - DBG("%d:%d: %dx%d: paddr=%pad stride=%d", i, j, w, h, - &entry->paddr, + DBG("%d:%d: %dx%d: dma_addr=%pad stride=%d", i, j, w, h, + &entry->dma_addr, usergart[i].stride_pfn << PAGE_SHIFT); } } diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c index 024cf27d74db..806e8b981b2b 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c @@ -31,7 +31,7 @@ static struct sg_table *omap_gem_map_dma_buf( { struct drm_gem_object *obj = attachment->dmabuf->priv; struct sg_table *sg; - dma_addr_t paddr; + dma_addr_t dma_addr; int ret; sg = kzalloc(sizeof(*sg), GFP_KERNEL); @@ -41,7 +41,7 @@ static struct sg_table *omap_gem_map_dma_buf( /* camera, etc, need physically contiguous.. but we need a * better way to know this.. */ - ret = omap_gem_get_paddr(obj, &paddr); + ret = omap_gem_get_paddr(obj, &dma_addr); if (ret) goto out; @@ -51,8 +51,8 @@ static struct sg_table *omap_gem_map_dma_buf( sg_init_table(sg->sgl, 1); sg_dma_len(sg->sgl) = obj->size; - sg_set_page(sg->sgl, pfn_to_page(PFN_DOWN(paddr)), obj->size, 0); - sg_dma_address(sg->sgl) = paddr; + sg_set_page(sg->sgl, pfn_to_page(PFN_DOWN(dma_addr)), obj->size, 0); + sg_dma_address(sg->sgl) = dma_addr; /* this should be after _get_paddr() to ensure we have pages attached */ omap_gem_dma_sync(obj, dir); -- cgit v1.2.3 From bc20c85caba279b7c63146bab683ca1a81de9f79 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 21 Apr 2017 00:33:52 +0300 Subject: drm: omapdrm: Rename omap_gem_(get|put)_paddr() to omap_gem_(un)pin() The reflects the purpose of the function better. Signed-off-by: Laurent Pinchart Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/omap_drv.h | 4 ++-- drivers/gpu/drm/omapdrm/omap_fb.c | 6 ++--- drivers/gpu/drm/omapdrm/omap_fbdev.c | 9 ++++---- drivers/gpu/drm/omapdrm/omap_gem.c | 38 ++++++++++++++++++++++--------- drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 6 ++--- 5 files changed, 39 insertions(+), 24 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index ef5001f1f5c8..f2db84767bf8 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -188,8 +188,8 @@ int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll); void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff); void omap_gem_dma_sync(struct drm_gem_object *obj, enum dma_data_direction dir); -int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *dma_addr); -void omap_gem_put_paddr(struct drm_gem_object *obj); +int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr); +void omap_gem_unpin(struct drm_gem_object *obj); int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages, bool remap); int omap_gem_put_pages(struct drm_gem_object *obj); diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 444bf92c5252..2e8d77166e1f 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -259,7 +259,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb) for (i = 0; i < n; i++) { struct plane *plane = &omap_fb->planes[i]; - ret = omap_gem_get_paddr(plane->bo, &plane->dma_addr); + ret = omap_gem_pin(plane->bo, &plane->dma_addr); if (ret) goto fail; omap_gem_dma_sync(plane->bo, DMA_TO_DEVICE); @@ -274,7 +274,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb) fail: for (i--; i >= 0; i--) { struct plane *plane = &omap_fb->planes[i]; - omap_gem_put_paddr(plane->bo); + omap_gem_unpin(plane->bo); plane->dma_addr = 0; } @@ -300,7 +300,7 @@ void omap_framebuffer_unpin(struct drm_framebuffer *fb) for (i = 0; i < n; i++) { struct plane *plane = &omap_fb->planes[i]; - omap_gem_put_paddr(plane->bo); + omap_gem_unpin(plane->bo); plane->dma_addr = 0; } diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c index dabb1affa2ca..daf81a0a2899 100644 --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c @@ -162,10 +162,9 @@ static int omap_fbdev_create(struct drm_fb_helper *helper, * to it). Then we just need to be sure that we are able to re- * pin it in case of an opps. */ - ret = omap_gem_get_paddr(fbdev->bo, &dma_addr); + ret = omap_gem_pin(fbdev->bo, &dma_addr); if (ret) { - dev_err(dev->dev, - "could not map (paddr)! Skipping framebuffer alloc\n"); + dev_err(dev->dev, "could not pin framebuffer\n"); ret = -ENOMEM; goto fail; } @@ -303,8 +302,8 @@ void omap_fbdev_free(struct drm_device *dev) fbdev = to_omap_fbdev(priv->fbdev); - /* release the ref taken in omap_fbdev_create() */ - omap_gem_put_paddr(fbdev->bo); + /* unpin the GEM object pinned in omap_fbdev_create() */ + omap_gem_unpin(fbdev->bo); /* this will free the backing object */ if (fbdev->fb) diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 038a05918002..c9ad18ea31c8 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -66,9 +66,9 @@ struct omap_gem_object { * * Buffers mapped to the TILER have their DMA address pointing to the * TILER aperture. As TILER mappings are refcounted (through - * dma_addr_cnt) the DMA address must be accessed through - * omap_get_get_paddr() to ensure that the mapping won't disappear - * unexpectedly. References must be released with omap_gem_put_paddr(). + * dma_addr_cnt) the DMA address must be accessed through omap_gem_pin() + * to ensure that the mapping won't disappear unexpectedly. References + * must be released with omap_gem_unpin(). */ dma_addr_t dma_addr; @@ -784,10 +784,21 @@ void omap_gem_dma_sync(struct drm_gem_object *obj, } } -/* Get physical address for DMA.. if the buffer is not already contiguous, remap - * it to pin in physically contiguous memory.. (ie. map in TILER) +/** + * omap_gem_pin() - Pin a GEM object in memory + * @obj: the GEM object + * @dma_addr: the DMA address + * + * Pin the given GEM object in memory and fill the dma_addr pointer with the + * object's DMA address. If the buffer is not physically contiguous it will be + * remapped through the TILER to provide a contiguous view. + * + * Pins are reference-counted, calling this function multiple times is allowed + * as long the corresponding omap_gem_unpin() calls are balanced. + * + * Return 0 on success or a negative error code otherwise. */ -int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *dma_addr) +int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr) { struct omap_drm_private *priv = obj->dev->dev_private; struct omap_gem_object *omap_obj = to_omap_bo(obj); @@ -855,10 +866,15 @@ fail: return ret; } -/* Release physical address, when DMA is no longer being performed.. this - * could potentially unpin and unmap buffers from TILER +/** + * omap_gem_unpin() - Unpin a GEM object from memory + * @obj: the GEM object + * + * Unpin the given GEM object previously pinned with omap_gem_pin(). Pins are + * reference-counted, the actualy unpin will only be performed when the number + * of calls to this function matches the number of calls to omap_gem_pin(). */ -void omap_gem_put_paddr(struct drm_gem_object *obj) +void omap_gem_unpin(struct drm_gem_object *obj) { struct omap_gem_object *omap_obj = to_omap_bo(obj); int ret; @@ -919,9 +935,9 @@ int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient) * increasing the pin count (which we don't really do yet anyways, * because we don't support swapping pages back out). And 'remap' * might not be quite the right name, but I wanted to keep it working - * similarly to omap_gem_get_paddr(). Note though that mutex is not + * similarly to omap_gem_pin(). Note though that mutex is not * aquired if !remap (because this can be called in atomic ctxt), - * but probably omap_gem_get_paddr() should be changed to work in the + * but probably omap_gem_unpin() should be changed to work in the * same way. If !remap, a matching omap_gem_put_pages() call is not * required (and should not be made). */ diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c index 806e8b981b2b..6aaf28311f3a 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c @@ -41,7 +41,7 @@ static struct sg_table *omap_gem_map_dma_buf( /* camera, etc, need physically contiguous.. but we need a * better way to know this.. */ - ret = omap_gem_get_paddr(obj, &dma_addr); + ret = omap_gem_pin(obj, &dma_addr); if (ret) goto out; @@ -54,7 +54,7 @@ static struct sg_table *omap_gem_map_dma_buf( sg_set_page(sg->sgl, pfn_to_page(PFN_DOWN(dma_addr)), obj->size, 0); sg_dma_address(sg->sgl) = dma_addr; - /* this should be after _get_paddr() to ensure we have pages attached */ + /* this must be after omap_gem_pin() to ensure we have pages attached */ omap_gem_dma_sync(obj, dir); return sg; @@ -67,7 +67,7 @@ static void omap_gem_unmap_dma_buf(struct dma_buf_attachment *attachment, struct sg_table *sg, enum dma_data_direction dir) { struct drm_gem_object *obj = attachment->dmabuf->priv; - omap_gem_put_paddr(obj); + omap_gem_unpin(obj); sg_free_table(sg); kfree(sg); } -- cgit v1.2.3 From d61ce7da02a3c52317474f2a15dd610ec652d513 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 21 Apr 2017 00:33:55 +0300 Subject: drm: omapdrm: Rename GEM DMA sync functions The omap_gem_cpu_sync() function operates at a page level, while the omap_gem_dma_sync() function operates at a buffer level. Rename them to omap_gem_cpu_sync_page() and omap_gem_dma_sync_buffer() respectively to avoid confusion. Signed-off-by: Laurent Pinchart Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/omap_drv.h | 4 ++-- drivers/gpu/drm/omapdrm/omap_fb.c | 2 +- drivers/gpu/drm/omapdrm/omap_gem.c | 6 +++--- drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index f2db84767bf8..621f5aa0142f 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -185,8 +185,8 @@ int omap_gem_mmap_obj(struct drm_gem_object *obj, struct vm_area_struct *vma); int omap_gem_fault(struct vm_fault *vmf); int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll); -void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff); -void omap_gem_dma_sync(struct drm_gem_object *obj, +void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff); +void omap_gem_dma_sync_buffer(struct drm_gem_object *obj, enum dma_data_direction dir); int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr); void omap_gem_unpin(struct drm_gem_object *obj); diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 2e8d77166e1f..ee615fa048a5 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -262,7 +262,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb) ret = omap_gem_pin(plane->bo, &plane->dma_addr); if (ret) goto fail; - omap_gem_dma_sync(plane->bo, DMA_TO_DEVICE); + omap_gem_dma_sync_buffer(plane->bo, DMA_TO_DEVICE); } omap_fb->pin_count++; diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 6a5a4d07f675..86567e591f4e 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -388,7 +388,7 @@ static int fault_1d(struct drm_gem_object *obj, pgoff = (vmf->address - vma->vm_start) >> PAGE_SHIFT; if (omap_obj->pages) { - omap_gem_cpu_sync(obj, pgoff); + omap_gem_cpu_sync_page(obj, pgoff); pfn = page_to_pfn(omap_obj->pages[pgoff]); } else { BUG_ON(!is_contiguous(omap_obj)); @@ -734,7 +734,7 @@ static inline bool is_cached_coherent(struct drm_gem_object *obj) /* Sync the buffer for CPU access.. note pages should already be * attached, ie. omap_gem_get_pages() */ -void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff) +void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff) { struct drm_device *dev = obj->dev; struct omap_gem_object *omap_obj = to_omap_bo(obj); @@ -747,7 +747,7 @@ void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff) } /* sync the buffer for DMA access */ -void omap_gem_dma_sync(struct drm_gem_object *obj, +void omap_gem_dma_sync_buffer(struct drm_gem_object *obj, enum dma_data_direction dir) { struct drm_device *dev = obj->dev; diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c index 6aaf28311f3a..a2b91368c0b7 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c @@ -55,7 +55,7 @@ static struct sg_table *omap_gem_map_dma_buf( sg_dma_address(sg->sgl) = dma_addr; /* this must be after omap_gem_pin() to ensure we have pages attached */ - omap_gem_dma_sync(obj, dir); + omap_gem_dma_sync_buffer(obj, dir); return sg; out: @@ -112,7 +112,7 @@ static void *omap_gem_dmabuf_kmap_atomic(struct dma_buf *buffer, struct drm_gem_object *obj = buffer->priv; struct page **pages; omap_gem_get_pages(obj, &pages, false); - omap_gem_cpu_sync(obj, page_num); + omap_gem_cpu_sync_page(obj, page_num); return kmap_atomic(pages[page_num]); } @@ -128,7 +128,7 @@ static void *omap_gem_dmabuf_kmap(struct dma_buf *buffer, struct drm_gem_object *obj = buffer->priv; struct page **pages; omap_gem_get_pages(obj, &pages, false); - omap_gem_cpu_sync(obj, page_num); + omap_gem_cpu_sync_page(obj, page_num); return kmap(pages[page_num]); } -- cgit v1.2.3 From 2150c19b15b01458cfa0b2db68c7ad035011a1fb Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 21 Feb 2017 09:57:12 +0200 Subject: drm/omap: 64bit compile fixes Fix a few type issues that cause compile warnings on 64 bit ARM compiler. The change should not affect 32bit platforms. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 2 +- drivers/gpu/drm/omapdrm/omap_fb.c | 2 +- drivers/gpu/drm/omapdrm/omap_gem.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c index 3cab06661a08..1dd3dafc59af 100644 --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c @@ -388,7 +388,7 @@ struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, uint16_t w, u32 min_align = 128; int ret; unsigned long flags; - size_t slot_bytes; + u32 slot_bytes; BUG_ON(!validfmt(fmt)); diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index ee615fa048a5..4bf9fcfcf673 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -450,7 +450,7 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, if (size > omap_gem_mmap_size(bos[i]) - mode_cmd->offsets[i]) { dev_dbg(dev->dev, - "provided buffer object is too small! %d < %d\n", + "provided buffer object is too small! %zu < %d\n", bos[i]->size - mode_cmd->offsets[i], size); ret = -EINVAL; goto fail; diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 461fbb5c0075..13abf221d153 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1048,7 +1048,7 @@ void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m) area->p1.x, area->p1.y); } } else { - seq_printf(m, " %d", obj->size); + seq_printf(m, " %zu", obj->size); } seq_printf(m, "\n"); -- cgit v1.2.3 From 517a8a9564c0dea98e6d4e2c7f0fe4cbb9b8c9ba Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Wed, 3 May 2017 14:14:27 +0300 Subject: drm/omap: remove dma & vrfb rotation We have three rotation methods supported by the SoCs with DSS: DMA, VRFB and TILER. DMA rotation works in theory on all DSS platforms, but in practice it's unusable due to the huge amount of memory bandwidth it uses, and has never really been used. VRFB is available on OMAP3, but is not supported by omapdrm, even though we have some code for it in the dispc driver. TILER is supported on OMAP4/OMAP5/DRA7/AM5 platforms, but has some driver bugs. To clean up the driver to help fixing the TILER issues, this patch drops the DMA and VRFB rotation support, leaving only TILER rotation. Signed-off-by: Tomi Valkeinen Acked-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/dss/dispc.c | 248 +---------------------------- drivers/gpu/drm/omapdrm/dss/dss_features.c | 16 -- drivers/gpu/drm/omapdrm/dss/dss_features.h | 2 - drivers/gpu/drm/omapdrm/dss/omapdss.h | 5 +- drivers/gpu/drm/omapdrm/omap_fb.c | 2 +- drivers/gpu/drm/omapdrm/omap_plane.c | 2 +- 6 files changed, 10 insertions(+), 265 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index 802d3e72843b..77d10bf9285f 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -1908,230 +1908,7 @@ static s32 pixinc(int pixels, u8 ps) return 0; } -static void calc_vrfb_rotation_offset(u8 rotation, bool mirror, - u16 screen_width, - u16 width, u16 height, - enum omap_color_mode color_mode, bool fieldmode, - unsigned int field_offset, - unsigned *offset0, unsigned *offset1, - s32 *row_inc, s32 *pix_inc, int x_predecim, int y_predecim) -{ - u8 ps; - - switch (color_mode) { - case OMAP_DSS_COLOR_YUV2: - case OMAP_DSS_COLOR_UYVY: - ps = 4; - break; - default: - ps = color_mode_to_bpp(color_mode) / 8; - break; - } - - DSSDBG("calc_rot(%d): scrw %d, %dx%d\n", rotation, screen_width, - width, height); - - /* - * field 0 = even field = bottom field - * field 1 = odd field = top field - */ - switch (rotation + mirror * 4) { - case OMAP_DSS_ROT_0: - case OMAP_DSS_ROT_180: - /* - * If the pixel format is YUV or UYVY divide the width - * of the image by 2 for 0 and 180 degree rotation. - */ - if (color_mode == OMAP_DSS_COLOR_YUV2 || - color_mode == OMAP_DSS_COLOR_UYVY) - width = width >> 1; - case OMAP_DSS_ROT_90: - case OMAP_DSS_ROT_270: - *offset1 = 0; - if (field_offset) - *offset0 = field_offset * screen_width * ps; - else - *offset0 = 0; - - *row_inc = pixinc(1 + - (y_predecim * screen_width - x_predecim * width) + - (fieldmode ? screen_width : 0), ps); - *pix_inc = pixinc(x_predecim, ps); - break; - - case OMAP_DSS_ROT_0 + 4: - case OMAP_DSS_ROT_180 + 4: - /* If the pixel format is YUV or UYVY divide the width - * of the image by 2 for 0 degree and 180 degree - */ - if (color_mode == OMAP_DSS_COLOR_YUV2 || - color_mode == OMAP_DSS_COLOR_UYVY) - width = width >> 1; - case OMAP_DSS_ROT_90 + 4: - case OMAP_DSS_ROT_270 + 4: - *offset1 = 0; - if (field_offset) - *offset0 = field_offset * screen_width * ps; - else - *offset0 = 0; - *row_inc = pixinc(1 - - (y_predecim * screen_width + x_predecim * width) - - (fieldmode ? screen_width : 0), ps); - *pix_inc = pixinc(x_predecim, ps); - break; - - default: - BUG(); - return; - } -} - -static void calc_dma_rotation_offset(u8 rotation, bool mirror, - u16 screen_width, - u16 width, u16 height, - enum omap_color_mode color_mode, bool fieldmode, - unsigned int field_offset, - unsigned *offset0, unsigned *offset1, - s32 *row_inc, s32 *pix_inc, int x_predecim, int y_predecim) -{ - u8 ps; - u16 fbw, fbh; - - ps = color_mode_to_bpp(color_mode) / 8; - - DSSDBG("calc_rot(%d): scrw %d, %dx%d\n", rotation, screen_width, - width, height); - - /* width & height are overlay sizes, convert to fb sizes */ - - if (rotation == OMAP_DSS_ROT_0 || rotation == OMAP_DSS_ROT_180) { - fbw = width; - fbh = height; - } else { - fbw = height; - fbh = width; - } - - /* - * field 0 = even field = bottom field - * field 1 = odd field = top field - */ - switch (rotation + mirror * 4) { - case OMAP_DSS_ROT_0: - *offset1 = 0; - if (field_offset) - *offset0 = *offset1 + field_offset * screen_width * ps; - else - *offset0 = *offset1; - *row_inc = pixinc(1 + - (y_predecim * screen_width - fbw * x_predecim) + - (fieldmode ? screen_width : 0), ps); - if (color_mode == OMAP_DSS_COLOR_YUV2 || - color_mode == OMAP_DSS_COLOR_UYVY) - *pix_inc = pixinc(x_predecim, 2 * ps); - else - *pix_inc = pixinc(x_predecim, ps); - break; - case OMAP_DSS_ROT_90: - *offset1 = screen_width * (fbh - 1) * ps; - if (field_offset) - *offset0 = *offset1 + field_offset * ps; - else - *offset0 = *offset1; - *row_inc = pixinc(screen_width * (fbh * x_predecim - 1) + - y_predecim + (fieldmode ? 1 : 0), ps); - *pix_inc = pixinc(-x_predecim * screen_width, ps); - break; - case OMAP_DSS_ROT_180: - *offset1 = (screen_width * (fbh - 1) + fbw - 1) * ps; - if (field_offset) - *offset0 = *offset1 - field_offset * screen_width * ps; - else - *offset0 = *offset1; - *row_inc = pixinc(-1 - - (y_predecim * screen_width - fbw * x_predecim) - - (fieldmode ? screen_width : 0), ps); - if (color_mode == OMAP_DSS_COLOR_YUV2 || - color_mode == OMAP_DSS_COLOR_UYVY) - *pix_inc = pixinc(-x_predecim, 2 * ps); - else - *pix_inc = pixinc(-x_predecim, ps); - break; - case OMAP_DSS_ROT_270: - *offset1 = (fbw - 1) * ps; - if (field_offset) - *offset0 = *offset1 - field_offset * ps; - else - *offset0 = *offset1; - *row_inc = pixinc(-screen_width * (fbh * x_predecim - 1) - - y_predecim - (fieldmode ? 1 : 0), ps); - *pix_inc = pixinc(x_predecim * screen_width, ps); - break; - - /* mirroring */ - case OMAP_DSS_ROT_0 + 4: - *offset1 = (fbw - 1) * ps; - if (field_offset) - *offset0 = *offset1 + field_offset * screen_width * ps; - else - *offset0 = *offset1; - *row_inc = pixinc(y_predecim * screen_width * 2 - 1 + - (fieldmode ? screen_width : 0), - ps); - if (color_mode == OMAP_DSS_COLOR_YUV2 || - color_mode == OMAP_DSS_COLOR_UYVY) - *pix_inc = pixinc(-x_predecim, 2 * ps); - else - *pix_inc = pixinc(-x_predecim, ps); - break; - - case OMAP_DSS_ROT_90 + 4: - *offset1 = 0; - if (field_offset) - *offset0 = *offset1 + field_offset * ps; - else - *offset0 = *offset1; - *row_inc = pixinc(-screen_width * (fbh * x_predecim - 1) + - y_predecim + (fieldmode ? 1 : 0), - ps); - *pix_inc = pixinc(x_predecim * screen_width, ps); - break; - - case OMAP_DSS_ROT_180 + 4: - *offset1 = screen_width * (fbh - 1) * ps; - if (field_offset) - *offset0 = *offset1 - field_offset * screen_width * ps; - else - *offset0 = *offset1; - *row_inc = pixinc(1 - y_predecim * screen_width * 2 - - (fieldmode ? screen_width : 0), - ps); - if (color_mode == OMAP_DSS_COLOR_YUV2 || - color_mode == OMAP_DSS_COLOR_UYVY) - *pix_inc = pixinc(x_predecim, 2 * ps); - else - *pix_inc = pixinc(x_predecim, ps); - break; - - case OMAP_DSS_ROT_270 + 4: - *offset1 = (screen_width * (fbh - 1) + fbw - 1) * ps; - if (field_offset) - *offset0 = *offset1 - field_offset * ps; - else - *offset0 = *offset1; - *row_inc = pixinc(screen_width * (fbh * x_predecim - 1) - - y_predecim - (fieldmode ? 1 : 0), - ps); - *pix_inc = pixinc(-x_predecim * screen_width, ps); - break; - - default: - BUG(); - return; - } -} - -static void calc_tiler_rotation_offset(u16 screen_width, u16 width, +static void calc_offset(u16 screen_width, u16 width, enum omap_color_mode color_mode, bool fieldmode, unsigned int field_offset, unsigned *offset0, unsigned *offset1, s32 *row_inc, s32 *pix_inc, int x_predecim, int y_predecim) @@ -2711,23 +2488,10 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane, frame_height = height; } - if (rotation_type == OMAP_DSS_ROT_TILER) - calc_tiler_rotation_offset(screen_width, frame_width, - color_mode, fieldmode, field_offset, - &offset0, &offset1, &row_inc, &pix_inc, - x_predecim, y_predecim); - else if (rotation_type == OMAP_DSS_ROT_DMA) - calc_dma_rotation_offset(rotation, mirror, screen_width, - frame_width, frame_height, - color_mode, fieldmode, field_offset, - &offset0, &offset1, &row_inc, &pix_inc, - x_predecim, y_predecim); - else - calc_vrfb_rotation_offset(rotation, mirror, - screen_width, frame_width, frame_height, - color_mode, fieldmode, field_offset, - &offset0, &offset1, &row_inc, &pix_inc, - x_predecim, y_predecim); + calc_offset(screen_width, frame_width, + color_mode, fieldmode, field_offset, + &offset0, &offset1, &row_inc, &pix_inc, + x_predecim, y_predecim); DSSDBG("offset0 %u, offset1 %u, row_inc %d, pix_inc %d\n", offset0, offset1, row_inc, pix_inc); @@ -4168,7 +3932,7 @@ static const struct dispc_errata_i734_data { .width = 1, .height = 1, .color_mode = OMAP_DSS_COLOR_RGB24U, .rotation = OMAP_DSS_ROT_0, - .rotation_type = OMAP_DSS_ROT_DMA, + .rotation_type = OMAP_DSS_ROT_NONE, .mirror = 0, .pos_x = 0, .pos_y = 0, .out_width = 0, .out_height = 0, diff --git a/drivers/gpu/drm/omapdrm/dss/dss_features.c b/drivers/gpu/drm/omapdrm/dss/dss_features.c index 135b2a511cf0..bdac1d645ef0 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss_features.c +++ b/drivers/gpu/drm/omapdrm/dss/dss_features.c @@ -51,8 +51,6 @@ struct omap_dss_features { const enum omap_overlay_caps *overlay_caps; const struct dss_param_range *dss_params; - const enum omap_dss_rotation_type supported_rotation_types; - const u32 buffer_size_unit; const u32 burst_size_unit; }; @@ -596,7 +594,6 @@ static const struct omap_dss_features omap2_dss_features = { .supported_color_modes = omap2_dss_supported_color_modes, .overlay_caps = omap2_dss_overlay_caps, .dss_params = omap2_dss_param_range, - .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_VRFB, .buffer_size_unit = 1, .burst_size_unit = 8, }; @@ -616,7 +613,6 @@ static const struct omap_dss_features omap3430_dss_features = { .supported_color_modes = omap3_dss_supported_color_modes, .overlay_caps = omap3430_dss_overlay_caps, .dss_params = omap3_dss_param_range, - .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_VRFB, .buffer_size_unit = 1, .burst_size_unit = 8, }; @@ -639,7 +635,6 @@ static const struct omap_dss_features am35xx_dss_features = { .supported_color_modes = omap3_dss_supported_color_modes, .overlay_caps = omap3430_dss_overlay_caps, .dss_params = omap3_dss_param_range, - .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_VRFB, .buffer_size_unit = 1, .burst_size_unit = 8, }; @@ -658,7 +653,6 @@ static const struct omap_dss_features am43xx_dss_features = { .supported_color_modes = omap3_dss_supported_color_modes, .overlay_caps = omap3430_dss_overlay_caps, .dss_params = am43xx_dss_param_range, - .supported_rotation_types = OMAP_DSS_ROT_DMA, .buffer_size_unit = 1, .burst_size_unit = 8, }; @@ -677,7 +671,6 @@ static const struct omap_dss_features omap3630_dss_features = { .supported_color_modes = omap3_dss_supported_color_modes, .overlay_caps = omap3630_dss_overlay_caps, .dss_params = omap3_dss_param_range, - .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_VRFB, .buffer_size_unit = 1, .burst_size_unit = 8, }; @@ -698,7 +691,6 @@ static const struct omap_dss_features omap4430_es1_0_dss_features = { .supported_color_modes = omap4_dss_supported_color_modes, .overlay_caps = omap4_dss_overlay_caps, .dss_params = omap4_dss_param_range, - .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_TILER, .buffer_size_unit = 16, .burst_size_unit = 16, }; @@ -718,7 +710,6 @@ static const struct omap_dss_features omap4430_es2_0_1_2_dss_features = { .supported_color_modes = omap4_dss_supported_color_modes, .overlay_caps = omap4_dss_overlay_caps, .dss_params = omap4_dss_param_range, - .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_TILER, .buffer_size_unit = 16, .burst_size_unit = 16, }; @@ -738,7 +729,6 @@ static const struct omap_dss_features omap4_dss_features = { .supported_color_modes = omap4_dss_supported_color_modes, .overlay_caps = omap4_dss_overlay_caps, .dss_params = omap4_dss_param_range, - .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_TILER, .buffer_size_unit = 16, .burst_size_unit = 16, }; @@ -758,7 +748,6 @@ static const struct omap_dss_features omap5_dss_features = { .supported_color_modes = omap4_dss_supported_color_modes, .overlay_caps = omap4_dss_overlay_caps, .dss_params = omap5_dss_param_range, - .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_TILER, .buffer_size_unit = 16, .burst_size_unit = 16, }; @@ -845,11 +834,6 @@ void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end) *end = omap_current_dss_features->reg_fields[id].end; } -bool dss_feat_rotation_type_supported(enum omap_dss_rotation_type rot_type) -{ - return omap_current_dss_features->supported_rotation_types & rot_type; -} - void dss_features_init(enum omapdss_version version) { switch (version) { diff --git a/drivers/gpu/drm/omapdrm/dss/dss_features.h b/drivers/gpu/drm/omapdrm/dss/dss_features.h index 27fbe64935e8..6f262887502d 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss_features.h +++ b/drivers/gpu/drm/omapdrm/dss/dss_features.h @@ -95,8 +95,6 @@ bool dss_feat_color_mode_supported(enum omap_plane_id plane, u32 dss_feat_get_buffer_size_unit(void); /* in bytes */ u32 dss_feat_get_burst_size_unit(void); /* in bytes */ -bool dss_feat_rotation_type_supported(enum omap_dss_rotation_type rot_type); - bool dss_has_feature(enum dss_feat_id id); void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end); void dss_features_init(enum omapdss_version version); diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index 51d2403c201b..c33b53f27e0d 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -159,9 +159,8 @@ enum omap_dss_display_state { }; enum omap_dss_rotation_type { - OMAP_DSS_ROT_DMA = 1 << 0, - OMAP_DSS_ROT_VRFB = 1 << 1, - OMAP_DSS_ROT_TILER = 1 << 2, + OMAP_DSS_ROT_NONE = 0, + OMAP_DSS_ROT_TILER = 1 << 0, }; /* clockwise rotation angle */ diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 4bf9fcfcf673..1d2a94df7054 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -221,7 +221,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, } info->paddr = get_linear_addr(plane, format, 0, x, y); - info->rotation_type = OMAP_DSS_ROT_DMA; + info->rotation_type = OMAP_DSS_ROT_NONE; info->screen_width = plane->pitch; } diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index 8b343aa84098..40747a625374 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -68,7 +68,7 @@ static void omap_plane_atomic_update(struct drm_plane *plane, DBG("%s, crtc=%p fb=%p", omap_plane->name, state->crtc, state->fb); memset(&info, 0, sizeof(info)); - info.rotation_type = OMAP_DSS_ROT_DMA; + info.rotation_type = OMAP_DSS_ROT_NONE; info.rotation = OMAP_DSS_ROT_0; info.global_alpha = 0xff; info.mirror = 0; -- cgit v1.2.3 From 18c0d6217a4898b9cae1b999e0dd37f8239ba0ae Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Thu, 4 May 2017 10:27:53 +0300 Subject: drm/omap: change supported_modes to an array enum omap_color_mode is a bitmask, so at the moment we present the supported color modes as mask. To be able to move to fourccs, we need to use an array to present the supported color modes. As a first step towards fourccs, this patch changes the code to use an array to store the enums. Signed-off-by: Tomi Valkeinen Acked-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/dss/dispc.c | 2 +- drivers/gpu/drm/omapdrm/dss/dss_features.c | 153 +++++++++++++++++------------ drivers/gpu/drm/omapdrm/dss/dss_features.h | 2 +- drivers/gpu/drm/omapdrm/dss/omapdss.h | 2 +- drivers/gpu/drm/omapdrm/omap_drv.h | 2 +- drivers/gpu/drm/omapdrm/omap_fb.c | 14 ++- 6 files changed, 103 insertions(+), 72 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index ee874129b202..5836756a23a9 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -1140,7 +1140,7 @@ static u32 dispc_ovl_get_burst_size(enum omap_plane_id plane) return unit * 8; } -static enum omap_color_mode dispc_ovl_get_color_modes(enum omap_plane_id plane) +static const enum omap_color_mode *dispc_ovl_get_color_modes(enum omap_plane_id plane) { return dss_feat_get_supported_color_modes(plane); } diff --git a/drivers/gpu/drm/omapdrm/dss/dss_features.c b/drivers/gpu/drm/omapdrm/dss/dss_features.c index bdac1d645ef0..f9b0324cc263 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss_features.c +++ b/drivers/gpu/drm/omapdrm/dss/dss_features.c @@ -47,7 +47,7 @@ struct omap_dss_features { const int num_ovls; const enum omap_display_type *supported_displays; const enum omap_dss_output_id *supported_outputs; - const enum omap_color_mode *supported_color_modes; + const enum omap_color_mode **supported_color_modes; const enum omap_overlay_caps *overlay_caps; const struct dss_param_range *dss_params; @@ -229,90 +229,104 @@ static const enum omap_dss_output_id omap5_dss_supported_outputs[] = { OMAP_DSS_OUTPUT_DSI2, }; -static const enum omap_color_mode omap2_dss_supported_color_modes[] = { +#define COLOR_ARRAY(arr...) (const enum omap_color_mode[]) { arr, 0 } + +static const enum omap_color_mode *omap2_dss_supported_color_modes[] = { + /* OMAP_DSS_GFX */ - OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 | - OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P, + COLOR_ARRAY( + OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_RGB16, + OMAP_DSS_COLOR_RGB24U, OMAP_DSS_COLOR_RGB24P), /* OMAP_DSS_VIDEO1 */ - OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U | - OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 | - OMAP_DSS_COLOR_UYVY, + COLOR_ARRAY( + OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB24U, + OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_YUV2, + OMAP_DSS_COLOR_UYVY), /* OMAP_DSS_VIDEO2 */ - OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U | - OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 | - OMAP_DSS_COLOR_UYVY, + COLOR_ARRAY( + OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB24U, + OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_YUV2, + OMAP_DSS_COLOR_UYVY), }; -static const enum omap_color_mode omap3_dss_supported_color_modes[] = { +static const enum omap_color_mode *omap3_dss_supported_color_modes[] = { /* OMAP_DSS_GFX */ - OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 | - OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U | - OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 | - OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32, + COLOR_ARRAY( + OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_ARGB16, + OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB24U, + OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_ARGB32, + OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_RGBX32), /* OMAP_DSS_VIDEO1 */ - OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P | - OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 | - OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_UYVY, + COLOR_ARRAY( + OMAP_DSS_COLOR_RGB24U, OMAP_DSS_COLOR_RGB24P, + OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_RGB16, + OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_UYVY), /* OMAP_DSS_VIDEO2 */ - OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 | - OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U | - OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 | - OMAP_DSS_COLOR_UYVY | OMAP_DSS_COLOR_ARGB32 | - OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32, + COLOR_ARRAY( + OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_ARGB16, + OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB24U, + OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_YUV2, + OMAP_DSS_COLOR_UYVY, OMAP_DSS_COLOR_ARGB32, + OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_RGBX32), }; -static const enum omap_color_mode omap4_dss_supported_color_modes[] = { +static const enum omap_color_mode *omap4_dss_supported_color_modes[] = { /* OMAP_DSS_GFX */ - OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 | - OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U | - OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 | - OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32 | - OMAP_DSS_COLOR_ARGB16_1555 | OMAP_DSS_COLOR_RGBX16 | - OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_XRGB16_1555, + COLOR_ARRAY( + OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_ARGB16, + OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB24U, + OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_ARGB32, + OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_RGBX32, + OMAP_DSS_COLOR_ARGB16_1555, OMAP_DSS_COLOR_RGBX16, + OMAP_DSS_COLOR_RGBA16, OMAP_DSS_COLOR_XRGB16_1555), /* OMAP_DSS_VIDEO1 */ - OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U | - OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 | - OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 | - OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U | - OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY | - OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 | - OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 | - OMAP_DSS_COLOR_RGBX32, + COLOR_ARRAY( + OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB12U, + OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_ARGB16_1555, + OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_NV12, + OMAP_DSS_COLOR_RGBA16, OMAP_DSS_COLOR_RGB24U, + OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_UYVY, + OMAP_DSS_COLOR_ARGB16, OMAP_DSS_COLOR_XRGB16_1555, + OMAP_DSS_COLOR_ARGB32, OMAP_DSS_COLOR_RGBX16, + OMAP_DSS_COLOR_RGBX32), /* OMAP_DSS_VIDEO2 */ - OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U | - OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 | - OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 | - OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U | - OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY | - OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 | - OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 | - OMAP_DSS_COLOR_RGBX32, + COLOR_ARRAY( + OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB12U, + OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_ARGB16_1555, + OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_NV12, + OMAP_DSS_COLOR_RGBA16, OMAP_DSS_COLOR_RGB24U, + OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_UYVY, + OMAP_DSS_COLOR_ARGB16, OMAP_DSS_COLOR_XRGB16_1555, + OMAP_DSS_COLOR_ARGB32, OMAP_DSS_COLOR_RGBX16, + OMAP_DSS_COLOR_RGBX32), /* OMAP_DSS_VIDEO3 */ - OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U | - OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 | - OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 | - OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U | - OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY | - OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 | - OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 | - OMAP_DSS_COLOR_RGBX32, + COLOR_ARRAY( + OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB12U, + OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_ARGB16_1555, + OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_NV12, + OMAP_DSS_COLOR_RGBA16, OMAP_DSS_COLOR_RGB24U, + OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_UYVY, + OMAP_DSS_COLOR_ARGB16, OMAP_DSS_COLOR_XRGB16_1555, + OMAP_DSS_COLOR_ARGB32, OMAP_DSS_COLOR_RGBX16, + OMAP_DSS_COLOR_RGBX32), /* OMAP_DSS_WB */ - OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U | - OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 | - OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 | - OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U | - OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY | - OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 | - OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 | - OMAP_DSS_COLOR_RGBX32, + COLOR_ARRAY( + OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB12U, + OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_ARGB16_1555, + OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_NV12, + OMAP_DSS_COLOR_RGBA16, OMAP_DSS_COLOR_RGB24U, + OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_UYVY, + OMAP_DSS_COLOR_ARGB16, OMAP_DSS_COLOR_XRGB16_1555, + OMAP_DSS_COLOR_ARGB32, OMAP_DSS_COLOR_RGBX16, + OMAP_DSS_COLOR_RGBX32), }; static const enum omap_overlay_caps omap2_dss_overlay_caps[] = { @@ -783,7 +797,7 @@ enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel return omap_current_dss_features->supported_outputs[channel]; } -enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane_id plane) +const enum omap_color_mode *dss_feat_get_supported_color_modes(enum omap_plane_id plane) { return omap_current_dss_features->supported_color_modes[plane]; } @@ -796,8 +810,17 @@ enum omap_overlay_caps dss_feat_get_overlay_caps(enum omap_plane_id plane) bool dss_feat_color_mode_supported(enum omap_plane_id plane, enum omap_color_mode color_mode) { - return omap_current_dss_features->supported_color_modes[plane] & - color_mode; + const enum omap_color_mode *modes; + unsigned int i; + + modes = omap_current_dss_features->supported_color_modes[plane]; + + for (i = 0; modes[i]; ++i) { + if (modes[i] == color_mode) + return true; + } + + return false; } u32 dss_feat_get_buffer_size_unit(void) diff --git a/drivers/gpu/drm/omapdrm/dss/dss_features.h b/drivers/gpu/drm/omapdrm/dss/dss_features.h index 6f262887502d..190cf62537b0 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss_features.h +++ b/drivers/gpu/drm/omapdrm/dss/dss_features.h @@ -104,6 +104,6 @@ enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel int dss_feat_get_num_mgrs(void); int dss_feat_get_num_ovls(void); -enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane_id plane); +const enum omap_color_mode *dss_feat_get_supported_color_modes(enum omap_plane_id plane); #endif diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index e12cfaeb5b24..83be1f57fdb5 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -734,7 +734,7 @@ struct dispc_ops { const struct videomode *vm, bool mem_to_mem, enum omap_channel channel); - enum omap_color_mode (*ovl_get_color_modes)(enum omap_plane_id plane); + const enum omap_color_mode *(*ovl_get_color_modes)(enum omap_plane_id plane); }; void dispc_set_ops(const struct dispc_ops *o); diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index ea3f575931c3..ef061a53e231 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -151,7 +151,7 @@ struct drm_encoder *omap_connector_attached_encoder( bool omap_connector_get_hdmi_mode(struct drm_connector *connector); uint32_t omap_framebuffer_get_formats(uint32_t *pixel_formats, - uint32_t max_formats, enum omap_color_mode supported_modes); + uint32_t max_formats, const enum omap_color_mode *supported_modes); struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev, struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd); struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 1d2a94df7054..6fb25d35bc0a 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -57,14 +57,22 @@ static const struct { /* convert from overlay's pixel formats bitmask to an array of fourcc's */ uint32_t omap_framebuffer_get_formats(uint32_t *pixel_formats, - uint32_t max_formats, enum omap_color_mode supported_modes) + uint32_t max_formats, const enum omap_color_mode *supported_modes) { uint32_t nformats = 0; int i = 0; - for (i = 0; i < ARRAY_SIZE(formats) && nformats < max_formats; i++) - if (formats[i].dss_format & supported_modes) + for (i = 0; i < ARRAY_SIZE(formats) && nformats < max_formats; i++) { + unsigned int t; + + for (t = 0; supported_modes[t]; ++t) { + if (supported_modes[t] != formats[i].dss_format) + continue; + pixel_formats[nformats++] = formats[i].pixel_format; + break; + } + } return nformats; } -- cgit v1.2.3 From 9c39d17e0614d18d809ccf2c3858994feb4fcdaa Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Thu, 4 May 2017 11:19:12 +0300 Subject: drm/omap: use u32 instead of enum omap_color_mode In this step we drop 'enum omap_color_mode', and use u32 instead. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/dss/dispc.c | 34 +++++++++++++++--------------- drivers/gpu/drm/omapdrm/dss/dss_features.c | 16 +++++++------- drivers/gpu/drm/omapdrm/dss/dss_features.h | 4 ++-- drivers/gpu/drm/omapdrm/dss/omapdss.h | 6 +++--- drivers/gpu/drm/omapdrm/omap_drv.h | 2 +- drivers/gpu/drm/omapdrm/omap_fb.c | 8 +++---- 6 files changed, 35 insertions(+), 35 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index 5836756a23a9..c935a83bbe89 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -77,7 +77,7 @@ struct dispc_features { int (*calc_scaling) (unsigned long pclk, unsigned long lclk, const struct videomode *vm, u16 width, u16 height, u16 out_width, u16 out_height, - enum omap_color_mode color_mode, bool *five_taps, + u32 color_mode, bool *five_taps, int *x_predecim, int *y_predecim, int *decim_x, int *decim_y, u16 pos_x, unsigned long *core_clk, bool mem_to_mem); unsigned long (*calc_core_clk) (unsigned long pclk, @@ -906,7 +906,7 @@ static void dispc_ovl_set_row_inc(enum omap_plane_id plane, s32 inc) } static void dispc_ovl_set_color_mode(enum omap_plane_id plane, - enum omap_color_mode color_mode) + u32 color_mode) { u32 m = 0; if (plane != OMAP_DSS_GFX) { @@ -978,7 +978,7 @@ static void dispc_ovl_set_color_mode(enum omap_plane_id plane, REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), m, 4, 1); } -static bool format_is_yuv(enum omap_color_mode color_mode) +static bool format_is_yuv(u32 color_mode) { switch (color_mode) { case OMAP_DSS_COLOR_YUV2: @@ -1140,7 +1140,7 @@ static u32 dispc_ovl_get_burst_size(enum omap_plane_id plane) return unit * 8; } -static const enum omap_color_mode *dispc_ovl_get_color_modes(enum omap_plane_id plane) +static const u32 *dispc_ovl_get_color_modes(enum omap_plane_id plane) { return dss_feat_get_supported_color_modes(plane); } @@ -1562,7 +1562,7 @@ static void dispc_ovl_set_scale_param(enum omap_plane_id plane, static void dispc_ovl_set_accu_uv(enum omap_plane_id plane, u16 orig_width, u16 orig_height, u16 out_width, u16 out_height, - bool ilace, enum omap_color_mode color_mode, u8 rotation) + bool ilace, u32 color_mode, u8 rotation) { int h_accu2_0, h_accu2_1; int v_accu2_0, v_accu2_1; @@ -1652,7 +1652,7 @@ static void dispc_ovl_set_scaling_common(enum omap_plane_id plane, u16 orig_width, u16 orig_height, u16 out_width, u16 out_height, bool ilace, bool five_taps, - bool fieldmode, enum omap_color_mode color_mode, + bool fieldmode, u32 color_mode, u8 rotation) { int accu0 = 0; @@ -1706,7 +1706,7 @@ static void dispc_ovl_set_scaling_uv(enum omap_plane_id plane, u16 orig_width, u16 orig_height, u16 out_width, u16 out_height, bool ilace, bool five_taps, - bool fieldmode, enum omap_color_mode color_mode, + bool fieldmode, u32 color_mode, u8 rotation) { int scale_x = out_width != orig_width; @@ -1785,7 +1785,7 @@ static void dispc_ovl_set_scaling(enum omap_plane_id plane, u16 orig_width, u16 orig_height, u16 out_width, u16 out_height, bool ilace, bool five_taps, - bool fieldmode, enum omap_color_mode color_mode, + bool fieldmode, u32 color_mode, u8 rotation) { BUG_ON(plane == OMAP_DSS_GFX); @@ -1807,7 +1807,7 @@ static void dispc_ovl_set_scaling(enum omap_plane_id plane, static void dispc_ovl_set_rotation_attrs(enum omap_plane_id plane, u8 rotation, enum omap_dss_rotation_type rotation_type, - bool mirroring, enum omap_color_mode color_mode) + bool mirroring, u32 color_mode) { bool row_repeat = false; int vidrot = 0; @@ -1878,7 +1878,7 @@ static void dispc_ovl_set_rotation_attrs(enum omap_plane_id plane, u8 rotation, } } -static int color_mode_to_bpp(enum omap_color_mode color_mode) +static int color_mode_to_bpp(u32 color_mode) { switch (color_mode) { case OMAP_DSS_COLOR_NV12: @@ -1920,7 +1920,7 @@ static s32 pixinc(int pixels, u8 ps) } static void calc_offset(u16 screen_width, u16 width, - enum omap_color_mode color_mode, bool fieldmode, + u32 color_mode, bool fieldmode, unsigned int field_offset, unsigned *offset0, unsigned *offset1, s32 *row_inc, s32 *pix_inc, int x_predecim, int y_predecim) { @@ -2007,7 +2007,7 @@ static int check_horiz_timing_omap3(unsigned long pclk, unsigned long lclk, static unsigned long calc_core_clk_five_taps(unsigned long pclk, const struct videomode *vm, u16 width, u16 height, u16 out_width, u16 out_height, - enum omap_color_mode color_mode) + u32 color_mode) { u32 core_clk = 0; u64 tmp; @@ -2100,7 +2100,7 @@ static unsigned long calc_core_clk_44xx(unsigned long pclk, u16 width, static int dispc_ovl_calc_scaling_24xx(unsigned long pclk, unsigned long lclk, const struct videomode *vm, u16 width, u16 height, u16 out_width, u16 out_height, - enum omap_color_mode color_mode, bool *five_taps, + u32 color_mode, bool *five_taps, int *x_predecim, int *y_predecim, int *decim_x, int *decim_y, u16 pos_x, unsigned long *core_clk, bool mem_to_mem) { @@ -2146,7 +2146,7 @@ static int dispc_ovl_calc_scaling_24xx(unsigned long pclk, unsigned long lclk, static int dispc_ovl_calc_scaling_34xx(unsigned long pclk, unsigned long lclk, const struct videomode *vm, u16 width, u16 height, u16 out_width, u16 out_height, - enum omap_color_mode color_mode, bool *five_taps, + u32 color_mode, bool *five_taps, int *x_predecim, int *y_predecim, int *decim_x, int *decim_y, u16 pos_x, unsigned long *core_clk, bool mem_to_mem) { @@ -2231,7 +2231,7 @@ again: static int dispc_ovl_calc_scaling_44xx(unsigned long pclk, unsigned long lclk, const struct videomode *vm, u16 width, u16 height, u16 out_width, u16 out_height, - enum omap_color_mode color_mode, bool *five_taps, + u32 color_mode, bool *five_taps, int *x_predecim, int *y_predecim, int *decim_x, int *decim_y, u16 pos_x, unsigned long *core_clk, bool mem_to_mem) { @@ -2296,7 +2296,7 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk, enum omap_overlay_caps caps, const struct videomode *vm, u16 width, u16 height, u16 out_width, u16 out_height, - enum omap_color_mode color_mode, bool *five_taps, + u32 color_mode, bool *five_taps, int *x_predecim, int *y_predecim, u16 pos_x, enum omap_dss_rotation_type rotation_type, bool mem_to_mem) { @@ -2371,7 +2371,7 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk, static int dispc_ovl_setup_common(enum omap_plane_id plane, enum omap_overlay_caps caps, u32 paddr, u32 p_uv_addr, u16 screen_width, int pos_x, int pos_y, u16 width, u16 height, - u16 out_width, u16 out_height, enum omap_color_mode color_mode, + u16 out_width, u16 out_height, u32 color_mode, u8 rotation, bool mirror, u8 zorder, u8 pre_mult_alpha, u8 global_alpha, enum omap_dss_rotation_type rotation_type, bool replication, const struct videomode *vm, diff --git a/drivers/gpu/drm/omapdrm/dss/dss_features.c b/drivers/gpu/drm/omapdrm/dss/dss_features.c index f9b0324cc263..5fef78e637db 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss_features.c +++ b/drivers/gpu/drm/omapdrm/dss/dss_features.c @@ -47,7 +47,7 @@ struct omap_dss_features { const int num_ovls; const enum omap_display_type *supported_displays; const enum omap_dss_output_id *supported_outputs; - const enum omap_color_mode **supported_color_modes; + const u32 **supported_color_modes; const enum omap_overlay_caps *overlay_caps; const struct dss_param_range *dss_params; @@ -229,9 +229,9 @@ static const enum omap_dss_output_id omap5_dss_supported_outputs[] = { OMAP_DSS_OUTPUT_DSI2, }; -#define COLOR_ARRAY(arr...) (const enum omap_color_mode[]) { arr, 0 } +#define COLOR_ARRAY(arr...) (const u32[]) { arr, 0 } -static const enum omap_color_mode *omap2_dss_supported_color_modes[] = { +static const u32 *omap2_dss_supported_color_modes[] = { /* OMAP_DSS_GFX */ COLOR_ARRAY( @@ -251,7 +251,7 @@ static const enum omap_color_mode *omap2_dss_supported_color_modes[] = { OMAP_DSS_COLOR_UYVY), }; -static const enum omap_color_mode *omap3_dss_supported_color_modes[] = { +static const u32 *omap3_dss_supported_color_modes[] = { /* OMAP_DSS_GFX */ COLOR_ARRAY( OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_ARGB16, @@ -274,7 +274,7 @@ static const enum omap_color_mode *omap3_dss_supported_color_modes[] = { OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_RGBX32), }; -static const enum omap_color_mode *omap4_dss_supported_color_modes[] = { +static const u32 *omap4_dss_supported_color_modes[] = { /* OMAP_DSS_GFX */ COLOR_ARRAY( OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_ARGB16, @@ -797,7 +797,7 @@ enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel return omap_current_dss_features->supported_outputs[channel]; } -const enum omap_color_mode *dss_feat_get_supported_color_modes(enum omap_plane_id plane) +const u32 *dss_feat_get_supported_color_modes(enum omap_plane_id plane) { return omap_current_dss_features->supported_color_modes[plane]; } @@ -808,9 +808,9 @@ enum omap_overlay_caps dss_feat_get_overlay_caps(enum omap_plane_id plane) } bool dss_feat_color_mode_supported(enum omap_plane_id plane, - enum omap_color_mode color_mode) + u32 color_mode) { - const enum omap_color_mode *modes; + const u32 *modes; unsigned int i; modes = omap_current_dss_features->supported_color_modes[plane]; diff --git a/drivers/gpu/drm/omapdrm/dss/dss_features.h b/drivers/gpu/drm/omapdrm/dss/dss_features.h index 190cf62537b0..8f48dc097717 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss_features.h +++ b/drivers/gpu/drm/omapdrm/dss/dss_features.h @@ -90,7 +90,7 @@ unsigned long dss_feat_get_param_min(enum dss_range_param param); unsigned long dss_feat_get_param_max(enum dss_range_param param); enum omap_overlay_caps dss_feat_get_overlay_caps(enum omap_plane_id plane); bool dss_feat_color_mode_supported(enum omap_plane_id plane, - enum omap_color_mode color_mode); + u32 color_mode); u32 dss_feat_get_buffer_size_unit(void); /* in bytes */ u32 dss_feat_get_burst_size_unit(void); /* in bytes */ @@ -104,6 +104,6 @@ enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel int dss_feat_get_num_mgrs(void); int dss_feat_get_num_ovls(void); -const enum omap_color_mode *dss_feat_get_supported_color_modes(enum omap_plane_id plane); +const u32 *dss_feat_get_supported_color_modes(enum omap_plane_id plane); #endif diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index 83be1f57fdb5..a3294fe356d9 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -282,7 +282,7 @@ struct omap_overlay_info { u16 screen_width; u16 width; u16 height; - enum omap_color_mode color_mode; + u32 color_mode; u8 rotation; enum omap_dss_rotation_type rotation_type; bool mirror; @@ -330,7 +330,7 @@ struct omap_dss_writeback_info { u16 buf_width; u16 width; u16 height; - enum omap_color_mode color_mode; + u32 color_mode; u8 rotation; enum omap_dss_rotation_type rotation_type; bool mirror; @@ -734,7 +734,7 @@ struct dispc_ops { const struct videomode *vm, bool mem_to_mem, enum omap_channel channel); - const enum omap_color_mode *(*ovl_get_color_modes)(enum omap_plane_id plane); + const u32 *(*ovl_get_color_modes)(enum omap_plane_id plane); }; void dispc_set_ops(const struct dispc_ops *o); diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index ef061a53e231..d78b3ff94a07 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -151,7 +151,7 @@ struct drm_encoder *omap_connector_attached_encoder( bool omap_connector_get_hdmi_mode(struct drm_connector *connector); uint32_t omap_framebuffer_get_formats(uint32_t *pixel_formats, - uint32_t max_formats, const enum omap_color_mode *supported_modes); + uint32_t max_formats, const u32 *supported_modes); struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev, struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd); struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 6fb25d35bc0a..71b3f25e61c2 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -31,7 +31,7 @@ /* DSS to DRM formats mapping */ static const struct { - enum omap_color_mode dss_format; + u32 dss_format; uint32_t pixel_format; } formats[] = { /* 16bpp [A]RGB: */ @@ -57,7 +57,7 @@ static const struct { /* convert from overlay's pixel formats bitmask to an array of fourcc's */ uint32_t omap_framebuffer_get_formats(uint32_t *pixel_formats, - uint32_t max_formats, const enum omap_color_mode *supported_modes) + uint32_t max_formats, const u32 *supported_modes) { uint32_t nformats = 0; int i = 0; @@ -91,7 +91,7 @@ struct omap_framebuffer { struct drm_framebuffer base; int pin_count; const struct drm_format_info *format; - enum omap_color_mode dss_format; + u32 dss_format; struct plane planes[2]; /* lock for pinning (pin_count and planes.dma_addr) */ struct mutex lock; @@ -395,7 +395,7 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, const struct drm_format_info *format = NULL; struct omap_framebuffer *omap_fb = NULL; struct drm_framebuffer *fb = NULL; - enum omap_color_mode dss_format = 0; + u32 dss_format = 0; unsigned int pitch = mode_cmd->pitches[0]; int ret, i; -- cgit v1.2.3 From 3e1d65cdf84f88affa718396a392f9f9a0d8a5f6 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Thu, 4 May 2017 10:40:46 +0300 Subject: drm/omap: use DRM_FORMAT_* instead of OMAP_DSS_COLOR_* This patch changes omapdrm to use DRM_FORMAT_* values instead of OMAP_DSS_COLOR_* enum. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/dss/dispc.c | 143 +++++++++++++++-------------- drivers/gpu/drm/omapdrm/dss/dss_features.c | 117 +++++++++++------------ drivers/gpu/drm/omapdrm/dss/omapdss.h | 16 +--- drivers/gpu/drm/omapdrm/omap_fb.c | 32 +++---- 4 files changed, 148 insertions(+), 160 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index c935a83bbe89..59af4dfc22da 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "omapdss.h" #include "dss.h" @@ -158,7 +159,7 @@ enum omap_color_component { */ DISPC_COLOR_COMPONENT_RGB_Y = 1 << 0, /* used for UV component for - * OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_UYVY, OMAP_DSS_COLOR_NV12 + * DRM_FORMAT_YUYV, DRM_FORMAT_UYVY, DRM_FORMAT_NV12 * color formats on OMAP4 */ DISPC_COLOR_COMPONENT_UV = 1 << 1, @@ -911,64 +912,64 @@ static void dispc_ovl_set_color_mode(enum omap_plane_id plane, u32 m = 0; if (plane != OMAP_DSS_GFX) { switch (color_mode) { - case OMAP_DSS_COLOR_NV12: + case DRM_FORMAT_NV12: m = 0x0; break; - case OMAP_DSS_COLOR_RGBX16: + case DRM_FORMAT_XRGB4444: m = 0x1; break; - case OMAP_DSS_COLOR_RGBA16: + case DRM_FORMAT_RGBA4444: m = 0x2; break; - case OMAP_DSS_COLOR_RGB12U: + case DRM_FORMAT_RGBX4444: m = 0x4; break; - case OMAP_DSS_COLOR_ARGB16: + case DRM_FORMAT_ARGB4444: m = 0x5; break; - case OMAP_DSS_COLOR_RGB16: + case DRM_FORMAT_RGB565: m = 0x6; break; - case OMAP_DSS_COLOR_ARGB16_1555: + case DRM_FORMAT_ARGB1555: m = 0x7; break; - case OMAP_DSS_COLOR_RGB24U: + case DRM_FORMAT_XRGB8888: m = 0x8; break; - case OMAP_DSS_COLOR_RGB24P: + case DRM_FORMAT_RGB888: m = 0x9; break; - case OMAP_DSS_COLOR_YUV2: + case DRM_FORMAT_YUYV: m = 0xa; break; - case OMAP_DSS_COLOR_UYVY: + case DRM_FORMAT_UYVY: m = 0xb; break; - case OMAP_DSS_COLOR_ARGB32: + case DRM_FORMAT_ARGB8888: m = 0xc; break; - case OMAP_DSS_COLOR_RGBA32: + case DRM_FORMAT_RGBA8888: m = 0xd; break; - case OMAP_DSS_COLOR_RGBX32: + case DRM_FORMAT_RGBX8888: m = 0xe; break; - case OMAP_DSS_COLOR_XRGB16_1555: + case DRM_FORMAT_XRGB1555: m = 0xf; break; default: BUG(); return; } } else { switch (color_mode) { - case OMAP_DSS_COLOR_RGB12U: + case DRM_FORMAT_RGBX4444: m = 0x4; break; - case OMAP_DSS_COLOR_ARGB16: + case DRM_FORMAT_ARGB4444: m = 0x5; break; - case OMAP_DSS_COLOR_RGB16: + case DRM_FORMAT_RGB565: m = 0x6; break; - case OMAP_DSS_COLOR_ARGB16_1555: + case DRM_FORMAT_ARGB1555: m = 0x7; break; - case OMAP_DSS_COLOR_RGB24U: + case DRM_FORMAT_XRGB8888: m = 0x8; break; - case OMAP_DSS_COLOR_RGB24P: + case DRM_FORMAT_RGB888: m = 0x9; break; - case OMAP_DSS_COLOR_RGBX16: + case DRM_FORMAT_XRGB4444: m = 0xa; break; - case OMAP_DSS_COLOR_RGBA16: + case DRM_FORMAT_RGBA4444: m = 0xb; break; - case OMAP_DSS_COLOR_ARGB32: + case DRM_FORMAT_ARGB8888: m = 0xc; break; - case OMAP_DSS_COLOR_RGBA32: + case DRM_FORMAT_RGBA8888: m = 0xd; break; - case OMAP_DSS_COLOR_RGBX32: + case DRM_FORMAT_RGBX8888: m = 0xe; break; - case OMAP_DSS_COLOR_XRGB16_1555: + case DRM_FORMAT_XRGB1555: m = 0xf; break; default: BUG(); return; @@ -981,9 +982,9 @@ static void dispc_ovl_set_color_mode(enum omap_plane_id plane, static bool format_is_yuv(u32 color_mode) { switch (color_mode) { - case OMAP_DSS_COLOR_YUV2: - case OMAP_DSS_COLOR_UYVY: - case OMAP_DSS_COLOR_NV12: + case DRM_FORMAT_YUYV: + case DRM_FORMAT_UYVY: + case DRM_FORMAT_NV12: return true; default: return false; @@ -1619,14 +1620,14 @@ static void dispc_ovl_set_accu_uv(enum omap_plane_id plane, } switch (color_mode) { - case OMAP_DSS_COLOR_NV12: + case DRM_FORMAT_NV12: if (ilace) accu_table = accu_nv12_ilace; else accu_table = accu_nv12; break; - case OMAP_DSS_COLOR_YUV2: - case OMAP_DSS_COLOR_UYVY: + case DRM_FORMAT_YUYV: + case DRM_FORMAT_UYVY: accu_table = accu_yuv; break; default: @@ -1727,7 +1728,7 @@ static void dispc_ovl_set_scaling_uv(enum omap_plane_id plane, out_height, ilace, color_mode, rotation); switch (color_mode) { - case OMAP_DSS_COLOR_NV12: + case DRM_FORMAT_NV12: if (chroma_upscale) { /* UV is subsampled by 2 horizontally and vertically */ orig_height >>= 1; @@ -1739,8 +1740,8 @@ static void dispc_ovl_set_scaling_uv(enum omap_plane_id plane, } break; - case OMAP_DSS_COLOR_YUV2: - case OMAP_DSS_COLOR_UYVY: + case DRM_FORMAT_YUYV: + case DRM_FORMAT_UYVY: /* For YUV422 with 90/270 rotation, we don't upsample chroma */ if (rotation == OMAP_DSS_ROT_0 || rotation == OMAP_DSS_ROT_180) { @@ -1812,8 +1813,8 @@ static void dispc_ovl_set_rotation_attrs(enum omap_plane_id plane, u8 rotation, bool row_repeat = false; int vidrot = 0; - if (color_mode == OMAP_DSS_COLOR_YUV2 || - color_mode == OMAP_DSS_COLOR_UYVY) { + if (color_mode == DRM_FORMAT_YUYV || + color_mode == DRM_FORMAT_UYVY) { if (mirroring) { switch (rotation) { @@ -1858,7 +1859,7 @@ static void dispc_ovl_set_rotation_attrs(enum omap_plane_id plane, u8 rotation, * NV12 in 1D mode must use ROTATION=1. Otherwise DSS will fetch extra * rows beyond the framebuffer, which may cause OCP error. */ - if (color_mode == OMAP_DSS_COLOR_NV12 && + if (color_mode == DRM_FORMAT_NV12 && rotation_type != OMAP_DSS_ROT_TILER) vidrot = 1; @@ -1867,9 +1868,9 @@ static void dispc_ovl_set_rotation_attrs(enum omap_plane_id plane, u8 rotation, REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), row_repeat ? 1 : 0, 18, 18); - if (dss_feat_color_mode_supported(plane, OMAP_DSS_COLOR_NV12)) { + if (dss_feat_color_mode_supported(plane, DRM_FORMAT_NV12)) { bool doublestride = - color_mode == OMAP_DSS_COLOR_NV12 && + color_mode == DRM_FORMAT_NV12 && rotation_type == OMAP_DSS_ROT_TILER && (rotation == OMAP_DSS_ROT_0 || rotation == OMAP_DSS_ROT_180); @@ -1881,24 +1882,24 @@ static void dispc_ovl_set_rotation_attrs(enum omap_plane_id plane, u8 rotation, static int color_mode_to_bpp(u32 color_mode) { switch (color_mode) { - case OMAP_DSS_COLOR_NV12: + case DRM_FORMAT_NV12: return 8; - case OMAP_DSS_COLOR_RGB12U: - case OMAP_DSS_COLOR_RGB16: - case OMAP_DSS_COLOR_ARGB16: - case OMAP_DSS_COLOR_YUV2: - case OMAP_DSS_COLOR_UYVY: - case OMAP_DSS_COLOR_RGBA16: - case OMAP_DSS_COLOR_RGBX16: - case OMAP_DSS_COLOR_ARGB16_1555: - case OMAP_DSS_COLOR_XRGB16_1555: + case DRM_FORMAT_RGBX4444: + case DRM_FORMAT_RGB565: + case DRM_FORMAT_ARGB4444: + case DRM_FORMAT_YUYV: + case DRM_FORMAT_UYVY: + case DRM_FORMAT_RGBA4444: + case DRM_FORMAT_XRGB4444: + case DRM_FORMAT_ARGB1555: + case DRM_FORMAT_XRGB1555: return 16; - case OMAP_DSS_COLOR_RGB24P: + case DRM_FORMAT_RGB888: return 24; - case OMAP_DSS_COLOR_RGB24U: - case OMAP_DSS_COLOR_ARGB32: - case OMAP_DSS_COLOR_RGBA32: - case OMAP_DSS_COLOR_RGBX32: + case DRM_FORMAT_XRGB8888: + case DRM_FORMAT_ARGB8888: + case DRM_FORMAT_RGBA8888: + case DRM_FORMAT_RGBX8888: return 32; default: BUG(); @@ -1939,8 +1940,8 @@ static void calc_offset(u16 screen_width, u16 width, *row_inc = pixinc(1 + (y_predecim * screen_width - width * x_predecim) + (fieldmode ? screen_width : 0), ps); - if (color_mode == OMAP_DSS_COLOR_YUV2 || - color_mode == OMAP_DSS_COLOR_UYVY) + if (color_mode == DRM_FORMAT_YUYV || + color_mode == DRM_FORMAT_UYVY) *pix_inc = pixinc(x_predecim, 2 * ps); else *pix_inc = pixinc(x_predecim, ps); @@ -2037,7 +2038,7 @@ static unsigned long calc_core_clk_five_taps(unsigned long pclk, do_div(tmp, out_width); core_clk = max_t(u32, core_clk, tmp); - if (color_mode == OMAP_DSS_COLOR_RGB24U) + if (color_mode == DRM_FORMAT_XRGB8888) core_clk <<= 1; } @@ -2265,7 +2266,7 @@ static int dispc_ovl_calc_scaling_44xx(unsigned long pclk, unsigned long lclk, return -EINVAL; } - if (*decim_x > 4 && color_mode != OMAP_DSS_COLOR_NV12) { + if (*decim_x > 4 && color_mode != DRM_FORMAT_NV12) { /* * Let's disable all scaling that requires horizontal * decimation with higher factor than 4, until we have @@ -2494,7 +2495,7 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane, dispc_ovl_set_ba0(plane, paddr + offset0); dispc_ovl_set_ba1(plane, paddr + offset1); - if (OMAP_DSS_COLOR_NV12 == color_mode) { + if (color_mode == DRM_FORMAT_NV12) { dispc_ovl_set_ba0_uv(plane, p_uv_addr + offset0); dispc_ovl_set_ba1_uv(plane, p_uv_addr + offset1); } @@ -2585,14 +2586,14 @@ int dispc_wb_setup(const struct omap_dss_writeback_info *wi, replication, vm, mem_to_mem); switch (wi->color_mode) { - case OMAP_DSS_COLOR_RGB16: - case OMAP_DSS_COLOR_RGB24P: - case OMAP_DSS_COLOR_ARGB16: - case OMAP_DSS_COLOR_RGBA16: - case OMAP_DSS_COLOR_RGB12U: - case OMAP_DSS_COLOR_ARGB16_1555: - case OMAP_DSS_COLOR_XRGB16_1555: - case OMAP_DSS_COLOR_RGBX16: + case DRM_FORMAT_RGB565: + case DRM_FORMAT_RGB888: + case DRM_FORMAT_ARGB4444: + case DRM_FORMAT_RGBA4444: + case DRM_FORMAT_RGBX4444: + case DRM_FORMAT_ARGB1555: + case DRM_FORMAT_XRGB1555: + case DRM_FORMAT_XRGB4444: truncation = true; break; default: @@ -3918,7 +3919,7 @@ static const struct dispc_errata_i734_data { .ovli = { .screen_width = 1, .width = 1, .height = 1, - .color_mode = OMAP_DSS_COLOR_RGB24U, + .color_mode = DRM_FORMAT_XRGB8888, .rotation = OMAP_DSS_ROT_0, .rotation_type = OMAP_DSS_ROT_NONE, .mirror = 0, diff --git a/drivers/gpu/drm/omapdrm/dss/dss_features.c b/drivers/gpu/drm/omapdrm/dss/dss_features.c index 5fef78e637db..32e21ed45f47 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss_features.c +++ b/drivers/gpu/drm/omapdrm/dss/dss_features.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "omapdss.h" #include "dss.h" @@ -235,98 +236,98 @@ static const u32 *omap2_dss_supported_color_modes[] = { /* OMAP_DSS_GFX */ COLOR_ARRAY( - OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_RGB16, - OMAP_DSS_COLOR_RGB24U, OMAP_DSS_COLOR_RGB24P), + DRM_FORMAT_RGBX4444, DRM_FORMAT_RGB565, + DRM_FORMAT_XRGB8888, DRM_FORMAT_RGB888), /* OMAP_DSS_VIDEO1 */ COLOR_ARRAY( - OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB24U, - OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_YUV2, - OMAP_DSS_COLOR_UYVY), + DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888, + DRM_FORMAT_RGB888, DRM_FORMAT_YUYV, + DRM_FORMAT_UYVY), /* OMAP_DSS_VIDEO2 */ COLOR_ARRAY( - OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB24U, - OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_YUV2, - OMAP_DSS_COLOR_UYVY), + DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888, + DRM_FORMAT_RGB888, DRM_FORMAT_YUYV, + DRM_FORMAT_UYVY), }; static const u32 *omap3_dss_supported_color_modes[] = { /* OMAP_DSS_GFX */ COLOR_ARRAY( - OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_ARGB16, - OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB24U, - OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_ARGB32, - OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_RGBX32), + DRM_FORMAT_RGBX4444, DRM_FORMAT_ARGB4444, + DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888, + DRM_FORMAT_RGB888, DRM_FORMAT_ARGB8888, + DRM_FORMAT_RGBA8888, DRM_FORMAT_RGBX8888), /* OMAP_DSS_VIDEO1 */ COLOR_ARRAY( - OMAP_DSS_COLOR_RGB24U, OMAP_DSS_COLOR_RGB24P, - OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_RGB16, - OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_UYVY), + DRM_FORMAT_XRGB8888, DRM_FORMAT_RGB888, + DRM_FORMAT_RGBX4444, DRM_FORMAT_RGB565, + DRM_FORMAT_YUYV, DRM_FORMAT_UYVY), /* OMAP_DSS_VIDEO2 */ COLOR_ARRAY( - OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_ARGB16, - OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB24U, - OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_YUV2, - OMAP_DSS_COLOR_UYVY, OMAP_DSS_COLOR_ARGB32, - OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_RGBX32), + DRM_FORMAT_RGBX4444, DRM_FORMAT_ARGB4444, + DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888, + DRM_FORMAT_RGB888, DRM_FORMAT_YUYV, + DRM_FORMAT_UYVY, DRM_FORMAT_ARGB8888, + DRM_FORMAT_RGBA8888, DRM_FORMAT_RGBX8888), }; static const u32 *omap4_dss_supported_color_modes[] = { /* OMAP_DSS_GFX */ COLOR_ARRAY( - OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_ARGB16, - OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB24U, - OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_ARGB32, - OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_RGBX32, - OMAP_DSS_COLOR_ARGB16_1555, OMAP_DSS_COLOR_RGBX16, - OMAP_DSS_COLOR_RGBA16, OMAP_DSS_COLOR_XRGB16_1555), + DRM_FORMAT_RGBX4444, DRM_FORMAT_ARGB4444, + DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888, + DRM_FORMAT_RGB888, DRM_FORMAT_ARGB8888, + DRM_FORMAT_RGBA8888, DRM_FORMAT_RGBX8888, + DRM_FORMAT_ARGB1555, DRM_FORMAT_XRGB4444, + DRM_FORMAT_RGBA4444, DRM_FORMAT_XRGB1555), /* OMAP_DSS_VIDEO1 */ COLOR_ARRAY( - OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB12U, - OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_ARGB16_1555, - OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_NV12, - OMAP_DSS_COLOR_RGBA16, OMAP_DSS_COLOR_RGB24U, - OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_UYVY, - OMAP_DSS_COLOR_ARGB16, OMAP_DSS_COLOR_XRGB16_1555, - OMAP_DSS_COLOR_ARGB32, OMAP_DSS_COLOR_RGBX16, - OMAP_DSS_COLOR_RGBX32), + DRM_FORMAT_RGB565, DRM_FORMAT_RGBX4444, + DRM_FORMAT_YUYV, DRM_FORMAT_ARGB1555, + DRM_FORMAT_RGBA8888, DRM_FORMAT_NV12, + DRM_FORMAT_RGBA4444, DRM_FORMAT_XRGB8888, + DRM_FORMAT_RGB888, DRM_FORMAT_UYVY, + DRM_FORMAT_ARGB4444, DRM_FORMAT_XRGB1555, + DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB4444, + DRM_FORMAT_RGBX8888), /* OMAP_DSS_VIDEO2 */ COLOR_ARRAY( - OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB12U, - OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_ARGB16_1555, - OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_NV12, - OMAP_DSS_COLOR_RGBA16, OMAP_DSS_COLOR_RGB24U, - OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_UYVY, - OMAP_DSS_COLOR_ARGB16, OMAP_DSS_COLOR_XRGB16_1555, - OMAP_DSS_COLOR_ARGB32, OMAP_DSS_COLOR_RGBX16, - OMAP_DSS_COLOR_RGBX32), + DRM_FORMAT_RGB565, DRM_FORMAT_RGBX4444, + DRM_FORMAT_YUYV, DRM_FORMAT_ARGB1555, + DRM_FORMAT_RGBA8888, DRM_FORMAT_NV12, + DRM_FORMAT_RGBA4444, DRM_FORMAT_XRGB8888, + DRM_FORMAT_RGB888, DRM_FORMAT_UYVY, + DRM_FORMAT_ARGB4444, DRM_FORMAT_XRGB1555, + DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB4444, + DRM_FORMAT_RGBX8888), /* OMAP_DSS_VIDEO3 */ COLOR_ARRAY( - OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB12U, - OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_ARGB16_1555, - OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_NV12, - OMAP_DSS_COLOR_RGBA16, OMAP_DSS_COLOR_RGB24U, - OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_UYVY, - OMAP_DSS_COLOR_ARGB16, OMAP_DSS_COLOR_XRGB16_1555, - OMAP_DSS_COLOR_ARGB32, OMAP_DSS_COLOR_RGBX16, - OMAP_DSS_COLOR_RGBX32), + DRM_FORMAT_RGB565, DRM_FORMAT_RGBX4444, + DRM_FORMAT_YUYV, DRM_FORMAT_ARGB1555, + DRM_FORMAT_RGBA8888, DRM_FORMAT_NV12, + DRM_FORMAT_RGBA4444, DRM_FORMAT_XRGB8888, + DRM_FORMAT_RGB888, DRM_FORMAT_UYVY, + DRM_FORMAT_ARGB4444, DRM_FORMAT_XRGB1555, + DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB4444, + DRM_FORMAT_RGBX8888), /* OMAP_DSS_WB */ COLOR_ARRAY( - OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB12U, - OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_ARGB16_1555, - OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_NV12, - OMAP_DSS_COLOR_RGBA16, OMAP_DSS_COLOR_RGB24U, - OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_UYVY, - OMAP_DSS_COLOR_ARGB16, OMAP_DSS_COLOR_XRGB16_1555, - OMAP_DSS_COLOR_ARGB32, OMAP_DSS_COLOR_RGBX16, - OMAP_DSS_COLOR_RGBX32), + DRM_FORMAT_RGB565, DRM_FORMAT_RGBX4444, + DRM_FORMAT_YUYV, DRM_FORMAT_ARGB1555, + DRM_FORMAT_RGBA8888, DRM_FORMAT_NV12, + DRM_FORMAT_RGBA4444, DRM_FORMAT_XRGB8888, + DRM_FORMAT_RGB888, DRM_FORMAT_UYVY, + DRM_FORMAT_ARGB4444, DRM_FORMAT_XRGB1555, + DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB4444, + DRM_FORMAT_RGBX8888), }; static const enum omap_overlay_caps omap2_dss_overlay_caps[] = { diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index a3294fe356d9..b339edcc91cf 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -92,21 +92,7 @@ enum omap_channel { }; enum omap_color_mode { - OMAP_DSS_COLOR_RGB12U = 1 << 4, /* RGB12, 16-bit container */ - OMAP_DSS_COLOR_ARGB16 = 1 << 5, /* ARGB16 */ - OMAP_DSS_COLOR_RGB16 = 1 << 6, /* RGB16 */ - OMAP_DSS_COLOR_RGB24U = 1 << 7, /* RGB24, 32-bit container */ - OMAP_DSS_COLOR_RGB24P = 1 << 8, /* RGB24, 24-bit container */ - OMAP_DSS_COLOR_YUV2 = 1 << 9, /* YUV2 4:2:2 co-sited */ - OMAP_DSS_COLOR_UYVY = 1 << 10, /* UYVY 4:2:2 co-sited */ - OMAP_DSS_COLOR_ARGB32 = 1 << 11, /* ARGB32 */ - OMAP_DSS_COLOR_RGBA32 = 1 << 12, /* RGBA32 */ - OMAP_DSS_COLOR_RGBX32 = 1 << 13, /* RGBx32 */ - OMAP_DSS_COLOR_NV12 = 1 << 14, /* NV12 format: YUV 4:2:0 */ - OMAP_DSS_COLOR_RGBA16 = 1 << 15, /* RGBA16 - 4444 */ - OMAP_DSS_COLOR_RGBX16 = 1 << 16, /* RGBx16 - 4444 */ - OMAP_DSS_COLOR_ARGB16_1555 = 1 << 17, /* ARGB16 - 1555 */ - OMAP_DSS_COLOR_XRGB16_1555 = 1 << 18, /* xRGB16 - 1555 */ + _UNUSED_, }; enum omap_dss_load_mode { diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 71b3f25e61c2..9d5f6ad2059e 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -35,24 +35,24 @@ static const struct { uint32_t pixel_format; } formats[] = { /* 16bpp [A]RGB: */ - { OMAP_DSS_COLOR_RGB16, DRM_FORMAT_RGB565 }, /* RGB16-565 */ - { OMAP_DSS_COLOR_RGB12U, DRM_FORMAT_RGBX4444 }, /* RGB12x-4444 */ - { OMAP_DSS_COLOR_RGBX16, DRM_FORMAT_XRGB4444 }, /* xRGB12-4444 */ - { OMAP_DSS_COLOR_RGBA16, DRM_FORMAT_RGBA4444 }, /* RGBA12-4444 */ - { OMAP_DSS_COLOR_ARGB16, DRM_FORMAT_ARGB4444 }, /* ARGB16-4444 */ - { OMAP_DSS_COLOR_XRGB16_1555, DRM_FORMAT_XRGB1555 }, /* xRGB15-1555 */ - { OMAP_DSS_COLOR_ARGB16_1555, DRM_FORMAT_ARGB1555 }, /* ARGB16-1555 */ + { DRM_FORMAT_RGB565, DRM_FORMAT_RGB565 }, /* RGB16-565 */ + { DRM_FORMAT_RGBX4444, DRM_FORMAT_RGBX4444 }, /* RGB12x-4444 */ + { DRM_FORMAT_XRGB4444, DRM_FORMAT_XRGB4444 }, /* xRGB12-4444 */ + { DRM_FORMAT_RGBA4444, DRM_FORMAT_RGBA4444 }, /* RGBA12-4444 */ + { DRM_FORMAT_ARGB4444, DRM_FORMAT_ARGB4444 }, /* ARGB16-4444 */ + { DRM_FORMAT_XRGB1555, DRM_FORMAT_XRGB1555 }, /* xRGB15-1555 */ + { DRM_FORMAT_ARGB1555, DRM_FORMAT_ARGB1555 }, /* ARGB16-1555 */ /* 24bpp RGB: */ - { OMAP_DSS_COLOR_RGB24P, DRM_FORMAT_RGB888 }, /* RGB24-888 */ + { DRM_FORMAT_RGB888, DRM_FORMAT_RGB888 }, /* RGB24-888 */ /* 32bpp [A]RGB: */ - { OMAP_DSS_COLOR_RGBX32, DRM_FORMAT_RGBX8888 }, /* RGBx24-8888 */ - { OMAP_DSS_COLOR_RGB24U, DRM_FORMAT_XRGB8888 }, /* xRGB24-8888 */ - { OMAP_DSS_COLOR_RGBA32, DRM_FORMAT_RGBA8888 }, /* RGBA32-8888 */ - { OMAP_DSS_COLOR_ARGB32, DRM_FORMAT_ARGB8888 }, /* ARGB32-8888 */ + { DRM_FORMAT_RGBX8888, DRM_FORMAT_RGBX8888 }, /* RGBx24-8888 */ + { DRM_FORMAT_XRGB8888, DRM_FORMAT_XRGB8888 }, /* xRGB24-8888 */ + { DRM_FORMAT_RGBA8888, DRM_FORMAT_RGBA8888 }, /* RGBA32-8888 */ + { DRM_FORMAT_ARGB8888, DRM_FORMAT_ARGB8888 }, /* ARGB32-8888 */ /* YUV: */ - { OMAP_DSS_COLOR_NV12, DRM_FORMAT_NV12 }, - { OMAP_DSS_COLOR_YUV2, DRM_FORMAT_YUYV }, - { OMAP_DSS_COLOR_UYVY, DRM_FORMAT_UYVY }, + { DRM_FORMAT_NV12, DRM_FORMAT_NV12 }, + { DRM_FORMAT_YUYV, DRM_FORMAT_YUYV }, + { DRM_FORMAT_UYVY, DRM_FORMAT_UYVY }, }; /* convert from overlay's pixel formats bitmask to an array of fourcc's */ @@ -236,7 +236,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, /* convert to pixels: */ info->screen_width /= format->cpp[0]; - if (omap_fb->dss_format == OMAP_DSS_COLOR_NV12) { + if (omap_fb->dss_format == DRM_FORMAT_NV12) { plane = &omap_fb->planes[1]; if (info->rotation_type == OMAP_DSS_ROT_TILER) { -- cgit v1.2.3 From eecad4371d986f38b66202817e2b461ac3c64139 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Thu, 4 May 2017 11:27:49 +0300 Subject: drm/omap: remove omap_framebuffer_get_formats() We now get a fourcc array from dispc when asking for a plane's supported pixel formats, so we can drop omap_framebuffer_get_formats() which was used to convert between DSS and DRM pixel formats. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/omap_drv.h | 2 -- drivers/gpu/drm/omapdrm/omap_fb.c | 22 ---------------------- drivers/gpu/drm/omapdrm/omap_plane.c | 15 +++++++-------- 3 files changed, 7 insertions(+), 32 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index d78b3ff94a07..ca087a993909 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -150,8 +150,6 @@ struct drm_encoder *omap_connector_attached_encoder( struct drm_connector *connector); bool omap_connector_get_hdmi_mode(struct drm_connector *connector); -uint32_t omap_framebuffer_get_formats(uint32_t *pixel_formats, - uint32_t max_formats, const u32 *supported_modes); struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev, struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd); struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 9d5f6ad2059e..489d17ce8f11 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -55,28 +55,6 @@ static const struct { { DRM_FORMAT_UYVY, DRM_FORMAT_UYVY }, }; -/* convert from overlay's pixel formats bitmask to an array of fourcc's */ -uint32_t omap_framebuffer_get_formats(uint32_t *pixel_formats, - uint32_t max_formats, const u32 *supported_modes) -{ - uint32_t nformats = 0; - int i = 0; - - for (i = 0; i < ARRAY_SIZE(formats) && nformats < max_formats; i++) { - unsigned int t; - - for (t = 0; supported_modes[t]; ++t) { - if (supported_modes[t] != formats[i].dss_format) - continue; - - pixel_formats[nformats++] = formats[i].pixel_format; - break; - } - } - - return nformats; -} - /* per-plane info for the fb: */ struct plane { struct drm_gem_object *bo; diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index 40747a625374..96c15e6d7397 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -34,9 +34,6 @@ struct omap_plane { struct drm_plane base; enum omap_plane_id id; const char *name; - - uint32_t nformats; - uint32_t formats[32]; }; static int omap_plane_prepare_fb(struct drm_plane *plane, @@ -294,6 +291,8 @@ struct drm_plane *omap_plane_init(struct drm_device *dev, struct omap_plane *omap_plane; enum omap_plane_id id; int ret; + u32 nformats; + const u32 *formats; if (WARN_ON(idx >= ARRAY_SIZE(plane_idx_to_id))) return ERR_PTR(-EINVAL); @@ -306,17 +305,17 @@ struct drm_plane *omap_plane_init(struct drm_device *dev, if (!omap_plane) return ERR_PTR(-ENOMEM); - omap_plane->nformats = omap_framebuffer_get_formats( - omap_plane->formats, ARRAY_SIZE(omap_plane->formats), - priv->dispc_ops->ovl_get_color_modes(id)); + formats = priv->dispc_ops->ovl_get_color_modes(id); + for (nformats = 0; formats[nformats]; ++nformats) + ; omap_plane->id = id; omap_plane->name = plane_id_to_name[id]; plane = &omap_plane->base; ret = drm_universal_plane_init(dev, plane, possible_crtcs, - &omap_plane_funcs, omap_plane->formats, - omap_plane->nformats, type, NULL); + &omap_plane_funcs, formats, + nformats, type, NULL); if (ret < 0) goto error; -- cgit v1.2.3 From c2e52e32049c0e94aa35a0635a2b150478ef3b2a Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Thu, 4 May 2017 11:29:58 +0300 Subject: drm/omap: cleanup formats array omap_fb.c has a table with DSS and DRM formats, used to convert between them. This is no longer needed, so we can change the array to a plain array of DRM_FORMAT_* values which contain all possible pixel formats supported by any DSS IP version. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/omap_fb.c | 49 ++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 29 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 489d17ce8f11..16b510dcee2f 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -29,30 +29,26 @@ * framebuffer funcs */ -/* DSS to DRM formats mapping */ -static const struct { - u32 dss_format; - uint32_t pixel_format; -} formats[] = { +static const u32 formats[] = { /* 16bpp [A]RGB: */ - { DRM_FORMAT_RGB565, DRM_FORMAT_RGB565 }, /* RGB16-565 */ - { DRM_FORMAT_RGBX4444, DRM_FORMAT_RGBX4444 }, /* RGB12x-4444 */ - { DRM_FORMAT_XRGB4444, DRM_FORMAT_XRGB4444 }, /* xRGB12-4444 */ - { DRM_FORMAT_RGBA4444, DRM_FORMAT_RGBA4444 }, /* RGBA12-4444 */ - { DRM_FORMAT_ARGB4444, DRM_FORMAT_ARGB4444 }, /* ARGB16-4444 */ - { DRM_FORMAT_XRGB1555, DRM_FORMAT_XRGB1555 }, /* xRGB15-1555 */ - { DRM_FORMAT_ARGB1555, DRM_FORMAT_ARGB1555 }, /* ARGB16-1555 */ + DRM_FORMAT_RGB565, /* RGB16-565 */ + DRM_FORMAT_RGBX4444, /* RGB12x-4444 */ + DRM_FORMAT_XRGB4444, /* xRGB12-4444 */ + DRM_FORMAT_RGBA4444, /* RGBA12-4444 */ + DRM_FORMAT_ARGB4444, /* ARGB16-4444 */ + DRM_FORMAT_XRGB1555, /* xRGB15-1555 */ + DRM_FORMAT_ARGB1555, /* ARGB16-1555 */ /* 24bpp RGB: */ - { DRM_FORMAT_RGB888, DRM_FORMAT_RGB888 }, /* RGB24-888 */ + DRM_FORMAT_RGB888, /* RGB24-888 */ /* 32bpp [A]RGB: */ - { DRM_FORMAT_RGBX8888, DRM_FORMAT_RGBX8888 }, /* RGBx24-8888 */ - { DRM_FORMAT_XRGB8888, DRM_FORMAT_XRGB8888 }, /* xRGB24-8888 */ - { DRM_FORMAT_RGBA8888, DRM_FORMAT_RGBA8888 }, /* RGBA32-8888 */ - { DRM_FORMAT_ARGB8888, DRM_FORMAT_ARGB8888 }, /* ARGB32-8888 */ + DRM_FORMAT_RGBX8888, /* RGBx24-8888 */ + DRM_FORMAT_XRGB8888, /* xRGB24-8888 */ + DRM_FORMAT_RGBA8888, /* RGBA32-8888 */ + DRM_FORMAT_ARGB8888, /* ARGB32-8888 */ /* YUV: */ - { DRM_FORMAT_NV12, DRM_FORMAT_NV12 }, - { DRM_FORMAT_YUYV, DRM_FORMAT_YUYV }, - { DRM_FORMAT_UYVY, DRM_FORMAT_UYVY }, + DRM_FORMAT_NV12, + DRM_FORMAT_YUYV, + DRM_FORMAT_UYVY, }; /* per-plane info for the fb: */ @@ -69,7 +65,6 @@ struct omap_framebuffer { struct drm_framebuffer base; int pin_count; const struct drm_format_info *format; - u32 dss_format; struct plane planes[2]; /* lock for pinning (pin_count and planes.dma_addr) */ struct mutex lock; @@ -137,7 +132,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, struct plane *plane = &omap_fb->planes[0]; uint32_t x, y, orient = 0; - info->color_mode = omap_fb->dss_format; + info->color_mode = fb->format->format; info->pos_x = win->crtc_x; info->pos_y = win->crtc_y; @@ -214,7 +209,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, /* convert to pixels: */ info->screen_width /= format->cpp[0]; - if (omap_fb->dss_format == DRM_FORMAT_NV12) { + if (fb->format->format == DRM_FORMAT_NV12) { plane = &omap_fb->planes[1]; if (info->rotation_type == OMAP_DSS_ROT_TILER) { @@ -373,7 +368,6 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, const struct drm_format_info *format = NULL; struct omap_framebuffer *omap_fb = NULL; struct drm_framebuffer *fb = NULL; - u32 dss_format = 0; unsigned int pitch = mode_cmd->pitches[0]; int ret, i; @@ -384,13 +378,11 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, format = drm_format_info(mode_cmd->pixel_format); for (i = 0; i < ARRAY_SIZE(formats); i++) { - if (formats[i].pixel_format == mode_cmd->pixel_format) { - dss_format = formats[i].dss_format; + if (formats[i] == mode_cmd->pixel_format) break; - } } - if (!format || !dss_format) { + if (!format || i == ARRAY_SIZE(formats)) { dev_dbg(dev->dev, "unsupported pixel format: %4.4s\n", (char *)&mode_cmd->pixel_format); ret = -EINVAL; @@ -405,7 +397,6 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, fb = &omap_fb->base; omap_fb->format = format; - omap_fb->dss_format = dss_format; mutex_init(&omap_fb->lock); /* -- cgit v1.2.3 From 41aff42ae6e3e9dbb800640fe3bb62383d4aa6e3 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Thu, 4 May 2017 11:31:56 +0300 Subject: drm/omap: rename color_mode to fourcc Now that we use fourccs, we can also rename the 'color_mode' variables to 'fourcc'. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/dss/dispc.c | 108 ++++++++++++++--------------- drivers/gpu/drm/omapdrm/dss/dss_features.c | 5 +- drivers/gpu/drm/omapdrm/dss/dss_features.h | 2 +- drivers/gpu/drm/omapdrm/dss/omapdss.h | 4 +- drivers/gpu/drm/omapdrm/omap_fb.c | 2 +- 5 files changed, 58 insertions(+), 63 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index 59af4dfc22da..7ccbcfc1d011 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -78,7 +78,7 @@ struct dispc_features { int (*calc_scaling) (unsigned long pclk, unsigned long lclk, const struct videomode *vm, u16 width, u16 height, u16 out_width, u16 out_height, - u32 color_mode, bool *five_taps, + u32 fourcc, bool *five_taps, int *x_predecim, int *y_predecim, int *decim_x, int *decim_y, u16 pos_x, unsigned long *core_clk, bool mem_to_mem); unsigned long (*calc_core_clk) (unsigned long pclk, @@ -906,12 +906,11 @@ static void dispc_ovl_set_row_inc(enum omap_plane_id plane, s32 inc) dispc_write_reg(DISPC_OVL_ROW_INC(plane), inc); } -static void dispc_ovl_set_color_mode(enum omap_plane_id plane, - u32 color_mode) +static void dispc_ovl_set_color_mode(enum omap_plane_id plane, u32 fourcc) { u32 m = 0; if (plane != OMAP_DSS_GFX) { - switch (color_mode) { + switch (fourcc) { case DRM_FORMAT_NV12: m = 0x0; break; case DRM_FORMAT_XRGB4444: @@ -946,7 +945,7 @@ static void dispc_ovl_set_color_mode(enum omap_plane_id plane, BUG(); return; } } else { - switch (color_mode) { + switch (fourcc) { case DRM_FORMAT_RGBX4444: m = 0x4; break; case DRM_FORMAT_ARGB4444: @@ -979,9 +978,9 @@ static void dispc_ovl_set_color_mode(enum omap_plane_id plane, REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), m, 4, 1); } -static bool format_is_yuv(u32 color_mode) +static bool format_is_yuv(u32 fourcc) { - switch (color_mode) { + switch (fourcc) { case DRM_FORMAT_YUYV: case DRM_FORMAT_UYVY: case DRM_FORMAT_NV12: @@ -1563,7 +1562,7 @@ static void dispc_ovl_set_scale_param(enum omap_plane_id plane, static void dispc_ovl_set_accu_uv(enum omap_plane_id plane, u16 orig_width, u16 orig_height, u16 out_width, u16 out_height, - bool ilace, u32 color_mode, u8 rotation) + bool ilace, u32 fourcc, u8 rotation) { int h_accu2_0, h_accu2_1; int v_accu2_0, v_accu2_1; @@ -1619,7 +1618,7 @@ static void dispc_ovl_set_accu_uv(enum omap_plane_id plane, return; } - switch (color_mode) { + switch (fourcc) { case DRM_FORMAT_NV12: if (ilace) accu_table = accu_nv12_ilace; @@ -1653,7 +1652,7 @@ static void dispc_ovl_set_scaling_common(enum omap_plane_id plane, u16 orig_width, u16 orig_height, u16 out_width, u16 out_height, bool ilace, bool five_taps, - bool fieldmode, u32 color_mode, + bool fieldmode, u32 fourcc, u8 rotation) { int accu0 = 0; @@ -1707,7 +1706,7 @@ static void dispc_ovl_set_scaling_uv(enum omap_plane_id plane, u16 orig_width, u16 orig_height, u16 out_width, u16 out_height, bool ilace, bool five_taps, - bool fieldmode, u32 color_mode, + bool fieldmode, u32 fourcc, u8 rotation) { int scale_x = out_width != orig_width; @@ -1717,7 +1716,7 @@ static void dispc_ovl_set_scaling_uv(enum omap_plane_id plane, if (!dss_has_feature(FEAT_HANDLE_UV_SEPARATE)) return; - if (!format_is_yuv(color_mode)) { + if (!format_is_yuv(fourcc)) { /* reset chroma resampling for RGB formats */ if (plane != OMAP_DSS_WB) REG_FLD_MOD(DISPC_OVL_ATTRIBUTES2(plane), 0, 8, 8); @@ -1725,9 +1724,9 @@ static void dispc_ovl_set_scaling_uv(enum omap_plane_id plane, } dispc_ovl_set_accu_uv(plane, orig_width, orig_height, out_width, - out_height, ilace, color_mode, rotation); + out_height, ilace, fourcc, rotation); - switch (color_mode) { + switch (fourcc) { case DRM_FORMAT_NV12: if (chroma_upscale) { /* UV is subsampled by 2 horizontally and vertically */ @@ -1786,7 +1785,7 @@ static void dispc_ovl_set_scaling(enum omap_plane_id plane, u16 orig_width, u16 orig_height, u16 out_width, u16 out_height, bool ilace, bool five_taps, - bool fieldmode, u32 color_mode, + bool fieldmode, u32 fourcc, u8 rotation) { BUG_ON(plane == OMAP_DSS_GFX); @@ -1795,26 +1794,25 @@ static void dispc_ovl_set_scaling(enum omap_plane_id plane, orig_width, orig_height, out_width, out_height, ilace, five_taps, - fieldmode, color_mode, + fieldmode, fourcc, rotation); dispc_ovl_set_scaling_uv(plane, orig_width, orig_height, out_width, out_height, ilace, five_taps, - fieldmode, color_mode, + fieldmode, fourcc, rotation); } static void dispc_ovl_set_rotation_attrs(enum omap_plane_id plane, u8 rotation, enum omap_dss_rotation_type rotation_type, - bool mirroring, u32 color_mode) + bool mirroring, u32 fourcc) { bool row_repeat = false; int vidrot = 0; - if (color_mode == DRM_FORMAT_YUYV || - color_mode == DRM_FORMAT_UYVY) { + if (fourcc == DRM_FORMAT_YUYV || fourcc == DRM_FORMAT_UYVY) { if (mirroring) { switch (rotation) { @@ -1859,8 +1857,7 @@ static void dispc_ovl_set_rotation_attrs(enum omap_plane_id plane, u8 rotation, * NV12 in 1D mode must use ROTATION=1. Otherwise DSS will fetch extra * rows beyond the framebuffer, which may cause OCP error. */ - if (color_mode == DRM_FORMAT_NV12 && - rotation_type != OMAP_DSS_ROT_TILER) + if (fourcc == DRM_FORMAT_NV12 && rotation_type != OMAP_DSS_ROT_TILER) vidrot = 1; REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), vidrot, 13, 12); @@ -1870,7 +1867,7 @@ static void dispc_ovl_set_rotation_attrs(enum omap_plane_id plane, u8 rotation, if (dss_feat_color_mode_supported(plane, DRM_FORMAT_NV12)) { bool doublestride = - color_mode == DRM_FORMAT_NV12 && + fourcc == DRM_FORMAT_NV12 && rotation_type == OMAP_DSS_ROT_TILER && (rotation == OMAP_DSS_ROT_0 || rotation == OMAP_DSS_ROT_180); @@ -1879,9 +1876,9 @@ static void dispc_ovl_set_rotation_attrs(enum omap_plane_id plane, u8 rotation, } } -static int color_mode_to_bpp(u32 color_mode) +static int color_mode_to_bpp(u32 fourcc) { - switch (color_mode) { + switch (fourcc) { case DRM_FORMAT_NV12: return 8; case DRM_FORMAT_RGBX4444: @@ -1921,13 +1918,13 @@ static s32 pixinc(int pixels, u8 ps) } static void calc_offset(u16 screen_width, u16 width, - u32 color_mode, bool fieldmode, + u32 fourcc, bool fieldmode, unsigned int field_offset, unsigned *offset0, unsigned *offset1, s32 *row_inc, s32 *pix_inc, int x_predecim, int y_predecim) { u8 ps; - ps = color_mode_to_bpp(color_mode) / 8; + ps = color_mode_to_bpp(fourcc) / 8; DSSDBG("scrw %d, width %d\n", screen_width, width); @@ -1940,8 +1937,7 @@ static void calc_offset(u16 screen_width, u16 width, *row_inc = pixinc(1 + (y_predecim * screen_width - width * x_predecim) + (fieldmode ? screen_width : 0), ps); - if (color_mode == DRM_FORMAT_YUYV || - color_mode == DRM_FORMAT_UYVY) + if (fourcc == DRM_FORMAT_YUYV || fourcc == DRM_FORMAT_UYVY) *pix_inc = pixinc(x_predecim, 2 * ps); else *pix_inc = pixinc(x_predecim, ps); @@ -2008,7 +2004,7 @@ static int check_horiz_timing_omap3(unsigned long pclk, unsigned long lclk, static unsigned long calc_core_clk_five_taps(unsigned long pclk, const struct videomode *vm, u16 width, u16 height, u16 out_width, u16 out_height, - u32 color_mode) + u32 fourcc) { u32 core_clk = 0; u64 tmp; @@ -2038,7 +2034,7 @@ static unsigned long calc_core_clk_five_taps(unsigned long pclk, do_div(tmp, out_width); core_clk = max_t(u32, core_clk, tmp); - if (color_mode == DRM_FORMAT_XRGB8888) + if (fourcc == DRM_FORMAT_XRGB8888) core_clk <<= 1; } @@ -2101,7 +2097,7 @@ static unsigned long calc_core_clk_44xx(unsigned long pclk, u16 width, static int dispc_ovl_calc_scaling_24xx(unsigned long pclk, unsigned long lclk, const struct videomode *vm, u16 width, u16 height, u16 out_width, u16 out_height, - u32 color_mode, bool *five_taps, + u32 fourcc, bool *five_taps, int *x_predecim, int *y_predecim, int *decim_x, int *decim_y, u16 pos_x, unsigned long *core_clk, bool mem_to_mem) { @@ -2147,7 +2143,7 @@ static int dispc_ovl_calc_scaling_24xx(unsigned long pclk, unsigned long lclk, static int dispc_ovl_calc_scaling_34xx(unsigned long pclk, unsigned long lclk, const struct videomode *vm, u16 width, u16 height, u16 out_width, u16 out_height, - u32 color_mode, bool *five_taps, + u32 fourcc, bool *five_taps, int *x_predecim, int *y_predecim, int *decim_x, int *decim_y, u16 pos_x, unsigned long *core_clk, bool mem_to_mem) { @@ -2169,7 +2165,7 @@ again: if (*five_taps) *core_clk = calc_core_clk_five_taps(pclk, vm, in_width, in_height, out_width, - out_height, color_mode); + out_height, fourcc); else *core_clk = dispc.feat->calc_core_clk(pclk, in_width, in_height, out_width, out_height, @@ -2232,7 +2228,7 @@ again: static int dispc_ovl_calc_scaling_44xx(unsigned long pclk, unsigned long lclk, const struct videomode *vm, u16 width, u16 height, u16 out_width, u16 out_height, - u32 color_mode, bool *five_taps, + u32 fourcc, bool *five_taps, int *x_predecim, int *y_predecim, int *decim_x, int *decim_y, u16 pos_x, unsigned long *core_clk, bool mem_to_mem) { @@ -2266,7 +2262,7 @@ static int dispc_ovl_calc_scaling_44xx(unsigned long pclk, unsigned long lclk, return -EINVAL; } - if (*decim_x > 4 && color_mode != DRM_FORMAT_NV12) { + if (*decim_x > 4 && fourcc != DRM_FORMAT_NV12) { /* * Let's disable all scaling that requires horizontal * decimation with higher factor than 4, until we have @@ -2297,7 +2293,7 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk, enum omap_overlay_caps caps, const struct videomode *vm, u16 width, u16 height, u16 out_width, u16 out_height, - u32 color_mode, bool *five_taps, + u32 fourcc, bool *five_taps, int *x_predecim, int *y_predecim, u16 pos_x, enum omap_dss_rotation_type rotation_type, bool mem_to_mem) { @@ -2336,7 +2332,7 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk, return -EINVAL; ret = dispc.feat->calc_scaling(pclk, lclk, vm, width, height, - out_width, out_height, color_mode, five_taps, + out_width, out_height, fourcc, five_taps, x_predecim, y_predecim, &decim_x, &decim_y, pos_x, &core_clk, mem_to_mem); if (ret) @@ -2372,7 +2368,7 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk, static int dispc_ovl_setup_common(enum omap_plane_id plane, enum omap_overlay_caps caps, u32 paddr, u32 p_uv_addr, u16 screen_width, int pos_x, int pos_y, u16 width, u16 height, - u16 out_width, u16 out_height, u32 color_mode, + u16 out_width, u16 out_height, u32 fourcc, u8 rotation, bool mirror, u8 zorder, u8 pre_mult_alpha, u8 global_alpha, enum omap_dss_rotation_type rotation_type, bool replication, const struct videomode *vm, @@ -2396,7 +2392,7 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane, if (paddr == 0 && rotation_type != OMAP_DSS_ROT_TILER) return -EINVAL; - if (format_is_yuv(color_mode) && (in_width & 1)) { + if (format_is_yuv(fourcc) && (in_width & 1)) { DSSERR("input width %d is not even for YUV format\n", in_width); return -EINVAL; } @@ -2418,11 +2414,11 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane, out_height); } - if (!dss_feat_color_mode_supported(plane, color_mode)) + if (!dss_feat_color_mode_supported(plane, fourcc)) return -EINVAL; r = dispc_ovl_calc_scaling(pclk, lclk, caps, vm, in_width, - in_height, out_width, out_height, color_mode, + in_height, out_width, out_height, fourcc, &five_taps, &x_predecim, &y_predecim, pos_x, rotation_type, mem_to_mem); if (r) @@ -2435,7 +2431,7 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane, DSSDBG("predecimation %d x %x, new input size %d x %d\n", x_predecim, y_predecim, in_width, in_height); - if (format_is_yuv(color_mode) && (in_width & 1)) { + if (format_is_yuv(fourcc) && (in_width & 1)) { DSSDBG("predecimated input width is not even for YUV format\n"); DSSDBG("adjusting input width %d -> %d\n", in_width, in_width & ~1); @@ -2443,7 +2439,7 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane, in_width &= ~1; } - if (format_is_yuv(color_mode)) + if (format_is_yuv(fourcc)) cconv = 1; if (ilace && !fieldmode) { @@ -2478,14 +2474,14 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane, } calc_offset(screen_width, frame_width, - color_mode, fieldmode, field_offset, + fourcc, fieldmode, field_offset, &offset0, &offset1, &row_inc, &pix_inc, x_predecim, y_predecim); DSSDBG("offset0 %u, offset1 %u, row_inc %d, pix_inc %d\n", offset0, offset1, row_inc, pix_inc); - dispc_ovl_set_color_mode(plane, color_mode); + dispc_ovl_set_color_mode(plane, fourcc); dispc_ovl_configure_burst_type(plane, rotation_type); @@ -2495,7 +2491,7 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane, dispc_ovl_set_ba0(plane, paddr + offset0); dispc_ovl_set_ba1(plane, paddr + offset1); - if (color_mode == DRM_FORMAT_NV12) { + if (fourcc == DRM_FORMAT_NV12) { dispc_ovl_set_ba0_uv(plane, p_uv_addr + offset0); dispc_ovl_set_ba1_uv(plane, p_uv_addr + offset1); } @@ -2516,13 +2512,13 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane, if (caps & OMAP_DSS_OVL_CAP_SCALE) { dispc_ovl_set_scaling(plane, in_width, in_height, out_width, out_height, ilace, five_taps, fieldmode, - color_mode, rotation); + fourcc, rotation); dispc_ovl_set_output_size(plane, out_width, out_height); dispc_ovl_set_vid_color_conv(plane, cconv); } dispc_ovl_set_rotation_attrs(plane, rotation, rotation_type, mirror, - color_mode); + fourcc); dispc_ovl_set_zorder(plane, caps, zorder); dispc_ovl_set_pre_mult_alpha(plane, caps, pre_mult_alpha); @@ -2546,13 +2542,13 @@ static int dispc_ovl_setup(enum omap_plane_id plane, " %dx%d, cmode %x, rot %d, mir %d, chan %d repl %d\n", plane, &oi->paddr, &oi->p_uv_addr, oi->screen_width, oi->pos_x, oi->pos_y, oi->width, oi->height, oi->out_width, oi->out_height, - oi->color_mode, oi->rotation, oi->mirror, channel, replication); + oi->fourcc, oi->rotation, oi->mirror, channel, replication); dispc_ovl_set_channel_out(plane, channel); r = dispc_ovl_setup_common(plane, caps, oi->paddr, oi->p_uv_addr, oi->screen_width, oi->pos_x, oi->pos_y, oi->width, oi->height, - oi->out_width, oi->out_height, oi->color_mode, oi->rotation, + oi->out_width, oi->out_height, oi->fourcc, oi->rotation, oi->mirror, oi->zorder, oi->pre_mult_alpha, oi->global_alpha, oi->rotation_type, replication, vm, mem_to_mem); @@ -2576,16 +2572,16 @@ int dispc_wb_setup(const struct omap_dss_writeback_info *wi, DSSDBG("dispc_wb_setup, pa %x, pa_uv %x, %d,%d -> %dx%d, cmode %x, " "rot %d, mir %d\n", wi->paddr, wi->p_uv_addr, in_width, - in_height, wi->width, wi->height, wi->color_mode, wi->rotation, + in_height, wi->width, wi->height, wi->fourcc, wi->rotation, wi->mirror); r = dispc_ovl_setup_common(plane, caps, wi->paddr, wi->p_uv_addr, wi->buf_width, pos_x, pos_y, in_width, in_height, wi->width, - wi->height, wi->color_mode, wi->rotation, wi->mirror, zorder, + wi->height, wi->fourcc, wi->rotation, wi->mirror, zorder, wi->pre_mult_alpha, global_alpha, wi->rotation_type, replication, vm, mem_to_mem); - switch (wi->color_mode) { + switch (wi->fourcc) { case DRM_FORMAT_RGB565: case DRM_FORMAT_RGB888: case DRM_FORMAT_ARGB4444: @@ -3919,7 +3915,7 @@ static const struct dispc_errata_i734_data { .ovli = { .screen_width = 1, .width = 1, .height = 1, - .color_mode = DRM_FORMAT_XRGB8888, + .fourcc = DRM_FORMAT_XRGB8888, .rotation = OMAP_DSS_ROT_0, .rotation_type = OMAP_DSS_ROT_NONE, .mirror = 0, @@ -3960,7 +3956,7 @@ static int dispc_errata_i734_wa_init(void) return 0; i734_buf.size = i734.ovli.width * i734.ovli.height * - color_mode_to_bpp(i734.ovli.color_mode) / 8; + color_mode_to_bpp(i734.ovli.fourcc) / 8; i734_buf.vaddr = dma_alloc_writecombine(&dispc.pdev->dev, i734_buf.size, &i734_buf.paddr, GFP_KERNEL); diff --git a/drivers/gpu/drm/omapdrm/dss/dss_features.c b/drivers/gpu/drm/omapdrm/dss/dss_features.c index 32e21ed45f47..0e599710dd95 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss_features.c +++ b/drivers/gpu/drm/omapdrm/dss/dss_features.c @@ -808,8 +808,7 @@ enum omap_overlay_caps dss_feat_get_overlay_caps(enum omap_plane_id plane) return omap_current_dss_features->overlay_caps[plane]; } -bool dss_feat_color_mode_supported(enum omap_plane_id plane, - u32 color_mode) +bool dss_feat_color_mode_supported(enum omap_plane_id plane, u32 fourcc) { const u32 *modes; unsigned int i; @@ -817,7 +816,7 @@ bool dss_feat_color_mode_supported(enum omap_plane_id plane, modes = omap_current_dss_features->supported_color_modes[plane]; for (i = 0; modes[i]; ++i) { - if (modes[i] == color_mode) + if (modes[i] == fourcc) return true; } diff --git a/drivers/gpu/drm/omapdrm/dss/dss_features.h b/drivers/gpu/drm/omapdrm/dss/dss_features.h index 8f48dc097717..c36436d27ff5 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss_features.h +++ b/drivers/gpu/drm/omapdrm/dss/dss_features.h @@ -90,7 +90,7 @@ unsigned long dss_feat_get_param_min(enum dss_range_param param); unsigned long dss_feat_get_param_max(enum dss_range_param param); enum omap_overlay_caps dss_feat_get_overlay_caps(enum omap_plane_id plane); bool dss_feat_color_mode_supported(enum omap_plane_id plane, - u32 color_mode); + u32 fourcc); u32 dss_feat_get_buffer_size_unit(void); /* in bytes */ u32 dss_feat_get_burst_size_unit(void); /* in bytes */ diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index b339edcc91cf..bbda9357241b 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -268,7 +268,7 @@ struct omap_overlay_info { u16 screen_width; u16 width; u16 height; - u32 color_mode; + u32 fourcc; u8 rotation; enum omap_dss_rotation_type rotation_type; bool mirror; @@ -316,7 +316,7 @@ struct omap_dss_writeback_info { u16 buf_width; u16 width; u16 height; - u32 color_mode; + u32 fourcc; u8 rotation; enum omap_dss_rotation_type rotation_type; bool mirror; diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 16b510dcee2f..c5b2088ee168 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -132,7 +132,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, struct plane *plane = &omap_fb->planes[0]; uint32_t x, y, orient = 0; - info->color_mode = fb->format->format; + info->fourcc = fb->format->format; info->pos_x = win->crtc_x; info->pos_y = win->crtc_y; -- cgit v1.2.3 From 8958aeb9c7bc86c89667af049243c47836111ab7 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 15 May 2017 12:57:46 +0300 Subject: drm/omap: add drm_rotation_to_tiler helper() Add a helper function to convert DRM rotation to TILER rotation. Also drop a error print that can never happen, as the DRM framework makes sure the rotation is valid. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/omap_fb.c | 56 ++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 25 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index c5b2088ee168..2f461d427924 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -122,6 +122,36 @@ bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb) return omap_gem_flags(plane->bo) & OMAP_BO_TILED; } +/* Note: DRM rotates counter-clockwise, TILER & DSS rotates clockwise */ +static uint32_t drm_rotation_to_tiler(unsigned int drm_rot) +{ + uint32_t orient; + + switch (drm_rot & DRM_MODE_ROTATE_MASK) { + default: + case DRM_MODE_ROTATE_0: + orient = 0; + break; + case DRM_MODE_ROTATE_90: + orient = MASK_XY_FLIP | MASK_X_INVERT; + break; + case DRM_MODE_ROTATE_180: + orient = MASK_X_INVERT | MASK_Y_INVERT; + break; + case DRM_MODE_ROTATE_270: + orient = MASK_XY_FLIP | MASK_Y_INVERT; + break; + } + + if (drm_rot & DRM_MODE_REFLECT_X) + orient ^= MASK_X_INVERT; + + if (drm_rot & DRM_MODE_REFLECT_Y) + orient ^= MASK_Y_INVERT; + + return orient; +} + /* update ovl info for scanout, handles cases of multi-planar fb's, etc. */ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, @@ -148,31 +178,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, uint32_t w = win->src_w; uint32_t h = win->src_h; - switch (win->rotation & DRM_MODE_ROTATE_MASK) { - default: - dev_err(fb->dev->dev, "invalid rotation: %02x", - (uint32_t)win->rotation); - /* fallthru to default to no rotation */ - case 0: - case DRM_MODE_ROTATE_0: - orient = 0; - break; - case DRM_MODE_ROTATE_90: - orient = MASK_XY_FLIP | MASK_X_INVERT; - break; - case DRM_MODE_ROTATE_180: - orient = MASK_X_INVERT | MASK_Y_INVERT; - break; - case DRM_MODE_ROTATE_270: - orient = MASK_XY_FLIP | MASK_Y_INVERT; - break; - } - - if (win->rotation & DRM_MODE_REFLECT_X) - orient ^= MASK_X_INVERT; - - if (win->rotation & DRM_MODE_REFLECT_Y) - orient ^= MASK_Y_INVERT; + orient = drm_rotation_to_tiler(win->rotation); /* adjust x,y offset for flip/invert: */ if (orient & MASK_XY_FLIP) -- cgit v1.2.3 From 218ed5358a4045382674f8feeee0efb526f9431b Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 15 May 2017 13:40:08 +0300 Subject: drm/omap: remove omap_drm_win struct omap_drm_window is only used to pass plane setup data to omap_framebuffer_update_scanout(). This can as well be accomplished by just passing the DRM state. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/omap_drv.h | 11 +---------- drivers/gpu/drm/omapdrm/omap_fb.c | 37 ++++++++++++++++++------------------ drivers/gpu/drm/omapdrm/omap_plane.c | 25 +----------------------- 3 files changed, 21 insertions(+), 52 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index ca087a993909..4bd1e9070b31 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -38,15 +38,6 @@ struct omap_drm_usergart; -/* parameters which describe (unrotated) coordinates of scanout within a fb: */ -struct omap_drm_window { - uint32_t rotation; - int32_t crtc_x, crtc_y; /* signed because can be offscreen */ - uint32_t crtc_w, crtc_h; - uint32_t src_x, src_y; - uint32_t src_w, src_h; -}; - /* For KMS code that needs to wait for a certain # of IRQs: */ struct omap_irq_wait; @@ -157,7 +148,7 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, int omap_framebuffer_pin(struct drm_framebuffer *fb); void omap_framebuffer_unpin(struct drm_framebuffer *fb); void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, - struct omap_drm_window *win, struct omap_overlay_info *info); + struct drm_plane_state *state, struct omap_overlay_info *info); struct drm_connector *omap_framebuffer_get_next_connector( struct drm_framebuffer *fb, struct drm_connector *from); bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb); diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 2f461d427924..4093e0e38a90 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -155,7 +155,7 @@ static uint32_t drm_rotation_to_tiler(unsigned int drm_rot) /* update ovl info for scanout, handles cases of multi-planar fb's, etc. */ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, - struct omap_drm_window *win, struct omap_overlay_info *info) + struct drm_plane_state *state, struct omap_overlay_info *info) { struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb); const struct drm_format_info *format = omap_fb->format; @@ -164,25 +164,27 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, info->fourcc = fb->format->format; - info->pos_x = win->crtc_x; - info->pos_y = win->crtc_y; - info->out_width = win->crtc_w; - info->out_height = win->crtc_h; - info->width = win->src_w; - info->height = win->src_h; + info->pos_x = state->crtc_x; + info->pos_y = state->crtc_y; + info->out_width = state->crtc_w; + info->out_height = state->crtc_h; + info->width = state->src_w >> 16; + info->height = state->src_h >> 16; - x = win->src_x; - y = win->src_y; + /* DSS driver wants the w & h in rotated orientation */ + if (drm_rotation_90_or_270(state->rotation)) + swap(info->width, info->height); + + x = state->src_x >> 16; + y = state->src_y >> 16; if (omap_gem_flags(plane->bo) & OMAP_BO_TILED) { - uint32_t w = win->src_w; - uint32_t h = win->src_h; + uint32_t w = state->src_w >> 16; + uint32_t h = state->src_h >> 16; - orient = drm_rotation_to_tiler(win->rotation); + orient = drm_rotation_to_tiler(state->rotation); - /* adjust x,y offset for flip/invert: */ - if (orient & MASK_XY_FLIP) - swap(w, h); + /* adjust x,y offset for invert: */ if (orient & MASK_Y_INVERT) y += h - 1; if (orient & MASK_X_INVERT) @@ -193,7 +195,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, info->rotation_type = OMAP_DSS_ROT_TILER; info->screen_width = omap_gem_tiled_stride(plane->bo, orient); } else { - switch (win->rotation & DRM_MODE_ROTATE_MASK) { + switch (state->rotation & DRM_MODE_ROTATE_MASK) { case 0: case DRM_MODE_ROTATE_0: /* OK */ @@ -202,8 +204,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, default: dev_warn(fb->dev->dev, "rotation '%d' ignored for non-tiled fb\n", - win->rotation); - win->rotation = 0; + state->rotation); break; } diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index 96c15e6d7397..08a446463afa 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -59,7 +59,6 @@ static void omap_plane_atomic_update(struct drm_plane *plane, struct omap_plane *omap_plane = to_omap_plane(plane); struct drm_plane_state *state = plane->state; struct omap_overlay_info info; - struct omap_drm_window win; int ret; DBG("%s, crtc=%p fb=%p", omap_plane->name, state->crtc, state->fb); @@ -71,30 +70,8 @@ static void omap_plane_atomic_update(struct drm_plane *plane, info.mirror = 0; info.zorder = state->zpos; - memset(&win, 0, sizeof(win)); - win.rotation = state->rotation; - win.crtc_x = state->crtc_x; - win.crtc_y = state->crtc_y; - win.crtc_w = state->crtc_w; - win.crtc_h = state->crtc_h; - - /* - * src values are in Q16 fixed point, convert to integer. - * omap_framebuffer_update_scanout() takes adjusted src. - */ - win.src_x = state->src_x >> 16; - win.src_y = state->src_y >> 16; - - if (drm_rotation_90_or_270(state->rotation)) { - win.src_w = state->src_h >> 16; - win.src_h = state->src_w >> 16; - } else { - win.src_w = state->src_w >> 16; - win.src_h = state->src_h >> 16; - } - /* update scanout: */ - omap_framebuffer_update_scanout(state->fb, &win, &info); + omap_framebuffer_update_scanout(state->fb, state, &info); DBG("%dx%d -> %dx%d (%d)", info.width, info.height, info.out_width, info.out_height, -- cgit v1.2.3 From 16f9ede51ff9b37e04fb64dad8b4099c2814c436 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 16 May 2017 12:48:58 +0300 Subject: drm/omap: pass rotation to dispc The omapdrm driver has not passed the rotation value to the dispc driver. This doesn't affect RGB formats, but YUV formats don't work without dispc knowing the orientation. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/omap_fb.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 4093e0e38a90..c7a805702b54 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -193,6 +193,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, omap_gem_rotated_dma_addr(plane->bo, orient, x, y, &info->paddr); info->rotation_type = OMAP_DSS_ROT_TILER; + info->rotation = state->rotation ?: DRM_MODE_ROTATE_0; info->screen_width = omap_gem_tiled_stride(plane->bo, orient); } else { switch (state->rotation & DRM_MODE_ROTATE_MASK) { @@ -210,6 +211,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, info->paddr = get_linear_addr(plane, format, 0, x, y); info->rotation_type = OMAP_DSS_ROT_NONE; + info->rotation = DRM_MODE_ROTATE_0; info->screen_width = plane->pitch; } -- cgit v1.2.3 From c4df6e4277503f0d05e261c3cae0c282fdca4437 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 15 May 2017 11:09:25 +0300 Subject: drm/omap: fix YUV422 rotation with TILER TILER rotation with YUV422 pixelformats does not work at the moment. All other pixel formats work, because the pixelformat's pixel size is equal to tiler unit size (e.g. XR24's pixel size is 32 bits, and the TILER unit size that has to be used is 32 bits). For YUV422 formats this is not the case, as the TILER unit size has to be 32 bits, but the pixel size is 16 bits. The end result is OCP errors and sync losts. This patch adds the code to adjust the variables for YUV422 formats. We could make the code more generic by passing around the pixel format, rotation type, angle and the tiler unit size, which would allow us to do calculations without special case for YUV422. However, this would make the code more complex, and at least for now this is much more easier to handle with these two special cases for YUV422. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/dss/dispc.c | 20 ++++++++++++++++++-- drivers/gpu/drm/omapdrm/omap_fb.c | 14 ++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c') diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index 53e2c93a5455..18e9dff2f1b2 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -1919,7 +1919,8 @@ static s32 pixinc(int pixels, u8 ps) static void calc_offset(u16 screen_width, u16 width, u32 fourcc, bool fieldmode, unsigned int field_offset, unsigned *offset0, unsigned *offset1, - s32 *row_inc, s32 *pix_inc, int x_predecim, int y_predecim) + s32 *row_inc, s32 *pix_inc, int x_predecim, int y_predecim, + enum omap_dss_rotation_type rotation_type, u8 rotation) { u8 ps; @@ -1927,6 +1928,20 @@ static void calc_offset(u16 screen_width, u16 width, DSSDBG("scrw %d, width %d\n", screen_width, width); + if (rotation_type == OMAP_DSS_ROT_TILER && + (fourcc == DRM_FORMAT_UYVY || fourcc == DRM_FORMAT_YUYV) && + drm_rotation_90_or_270(rotation)) { + /* + * HACK: ROW_INC needs to be calculated with TILER units. + * We get such 'screen_width' that multiplying it with the + * YUV422 pixel size gives the correct TILER container width. + * However, 'width' is in pixels and multiplying it with YUV422 + * pixel size gives incorrect result. We thus multiply it here + * with 2 to match the 32 bit TILER unit size. + */ + width *= 2; + } + /* * field 0 = even field = bottom field * field 1 = odd field = top field @@ -2475,7 +2490,8 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane, calc_offset(screen_width, frame_width, fourcc, fieldmode, field_offset, &offset0, &offset1, &row_inc, &pix_inc, - x_predecim, y_predecim); + x_predecim, y_predecim, + rotation_type, rotation); DSSDBG("offset0 %u, offset1 %u, row_inc %d, pix_inc %d\n", offset0, offset1, row_inc, pix_inc); diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index c7a805702b54..ddf7a457951b 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -184,16 +184,30 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, orient = drm_rotation_to_tiler(state->rotation); + /* + * omap_gem_rotated_paddr() wants the x & y in tiler units. + * Usually tiler unit size is the same as the pixel size, except + * for YUV422 formats, for which the tiler unit size is 32 bits + * and pixel size is 16 bits. + */ + if (fb->format->format == DRM_FORMAT_UYVY || + fb->format->format == DRM_FORMAT_YUYV) { + x /= 2; + w /= 2; + } + /* adjust x,y offset for invert: */ if (orient & MASK_Y_INVERT) y += h - 1; if (orient & MASK_X_INVERT) x += w - 1; + /* Note: x and y are in TILER units, not pixels */ omap_gem_rotated_dma_addr(plane->bo, orient, x, y, &info->paddr); info->rotation_type = OMAP_DSS_ROT_TILER; info->rotation = state->rotation ?: DRM_MODE_ROTATE_0; + /* Note: stride in TILER units, not pixels */ info->screen_width = omap_gem_tiled_stride(plane->bo, orient); } else { switch (state->rotation & DRM_MODE_ROTATE_MASK) { -- cgit v1.2.3