[PATCH 03/23] drm: omapdrm: fb: Store number of planes in format structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This replaces calls to drm_format_num_planes() by a simple field access
every time we need the number of planes for the frame buffer.

Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
---
 drivers/gpu/drm/omapdrm/omap_fb.c | 55 +++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index 2cc9f15fe439..ca7726e4d23e 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -31,6 +31,7 @@
 struct format {
 	enum omap_color_mode dss_format;
 	uint32_t pixel_format;
+	unsigned int num_planes;
 	int stride_bpp;           	/* this times width is stride */
 	int sub_y[2];			/* sub-sample in y dimension (per plane) */
 	bool yuv;
@@ -38,24 +39,24 @@ struct format {
 
 static const struct format formats[] = {
 	/* 16bpp [A]RGB: */
-	{ OMAP_DSS_COLOR_RGB16,       DRM_FORMAT_RGB565,   2, { 1, 0 }, false }, /* RGB16-565 */
-	{ OMAP_DSS_COLOR_RGB12U,      DRM_FORMAT_RGBX4444, 2, { 1, 0 }, false }, /* RGB12x-4444 */
-	{ OMAP_DSS_COLOR_RGBX16,      DRM_FORMAT_XRGB4444, 2, { 1, 0 }, false }, /* xRGB12-4444 */
-	{ OMAP_DSS_COLOR_RGBA16,      DRM_FORMAT_RGBA4444, 2, { 1, 0 }, false }, /* RGBA12-4444 */
-	{ OMAP_DSS_COLOR_ARGB16,      DRM_FORMAT_ARGB4444, 2, { 1, 0 }, false }, /* ARGB16-4444 */
-	{ OMAP_DSS_COLOR_XRGB16_1555, DRM_FORMAT_XRGB1555, 2, { 1, 0 }, false }, /* xRGB15-1555 */
-	{ OMAP_DSS_COLOR_ARGB16_1555, DRM_FORMAT_ARGB1555, 2, { 1, 0 }, false }, /* ARGB16-1555 */
+	{ OMAP_DSS_COLOR_RGB16,       DRM_FORMAT_RGB565,   1, 2, { 1, 0 }, false }, /* RGB16-565 */
+	{ OMAP_DSS_COLOR_RGB12U,      DRM_FORMAT_RGBX4444, 1, 2, { 1, 0 }, false }, /* RGB12x-4444 */
+	{ OMAP_DSS_COLOR_RGBX16,      DRM_FORMAT_XRGB4444, 1, 2, { 1, 0 }, false }, /* xRGB12-4444 */
+	{ OMAP_DSS_COLOR_RGBA16,      DRM_FORMAT_RGBA4444, 1, 2, { 1, 0 }, false }, /* RGBA12-4444 */
+	{ OMAP_DSS_COLOR_ARGB16,      DRM_FORMAT_ARGB4444, 1, 2, { 1, 0 }, false }, /* ARGB16-4444 */
+	{ OMAP_DSS_COLOR_XRGB16_1555, DRM_FORMAT_XRGB1555, 1, 2, { 1, 0 }, false }, /* xRGB15-1555 */
+	{ OMAP_DSS_COLOR_ARGB16_1555, DRM_FORMAT_ARGB1555, 1, 2, { 1, 0 }, false }, /* ARGB16-1555 */
 	/* 24bpp RGB: */
-	{ OMAP_DSS_COLOR_RGB24P,      DRM_FORMAT_RGB888,   3, { 1, 0 }, false }, /* RGB24-888 */
+	{ OMAP_DSS_COLOR_RGB24P,      DRM_FORMAT_RGB888,   1, 3, { 1, 0 }, false }, /* RGB24-888 */
 	/* 32bpp [A]RGB: */
-	{ OMAP_DSS_COLOR_RGBX32,      DRM_FORMAT_RGBX8888, 4, { 1, 0 }, false }, /* RGBx24-8888 */
-	{ OMAP_DSS_COLOR_RGB24U,      DRM_FORMAT_XRGB8888, 4, { 1, 0 }, false }, /* xRGB24-8888 */
-	{ OMAP_DSS_COLOR_RGBA32,      DRM_FORMAT_RGBA8888, 4, { 1, 0 }, false }, /* RGBA32-8888 */
-	{ OMAP_DSS_COLOR_ARGB32,      DRM_FORMAT_ARGB8888, 4, { 1, 0 }, false }, /* ARGB32-8888 */
+	{ OMAP_DSS_COLOR_RGBX32,      DRM_FORMAT_RGBX8888, 1, 4, { 1, 0 }, false }, /* RGBx24-8888 */
+	{ OMAP_DSS_COLOR_RGB24U,      DRM_FORMAT_XRGB8888, 1, 4, { 1, 0 }, false }, /* xRGB24-8888 */
+	{ OMAP_DSS_COLOR_RGBA32,      DRM_FORMAT_RGBA8888, 1, 4, { 1, 0 }, false }, /* RGBA32-8888 */
+	{ OMAP_DSS_COLOR_ARGB32,      DRM_FORMAT_ARGB8888, 1, 4, { 1, 0 }, false }, /* ARGB32-8888 */
 	/* YUV: */
-	{ OMAP_DSS_COLOR_NV12,        DRM_FORMAT_NV12,     1, { 1, 2 }, true },
-	{ OMAP_DSS_COLOR_YUV2,        DRM_FORMAT_YUYV,     2, { 1, 0 }, true },
-	{ OMAP_DSS_COLOR_UYVY,        DRM_FORMAT_UYVY,     2, { 1, 0 }, true },
+	{ OMAP_DSS_COLOR_NV12,        DRM_FORMAT_NV12,     2, 1, { 1, 2 }, true },
+	{ OMAP_DSS_COLOR_YUV2,        DRM_FORMAT_YUYV,     1, 2, { 1, 0 }, true },
+	{ OMAP_DSS_COLOR_UYVY,        DRM_FORMAT_UYVY,     1, 2, { 1, 0 }, true },
 };
 
 /* convert from overlay's pixel formats bitmask to an array of fourcc's */
@@ -103,13 +104,13 @@ static int omap_framebuffer_create_handle(struct drm_framebuffer *fb,
 static void omap_framebuffer_destroy(struct drm_framebuffer *fb)
 {
 	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	int i, n = drm_format_num_planes(fb->pixel_format);
+	int i;
 
 	DBG("destroy: FB ID: %d (%p)", fb->base.id, fb);
 
 	drm_framebuffer_cleanup(fb);
 
-	for (i = 0; i < n; i++) {
+	for (i = 0; i < omap_fb->format->num_planes; i++) {
 		struct plane *plane = &omap_fb->planes[i];
 		if (plane->bo)
 			drm_gem_object_unreference_unlocked(plane->bo);
@@ -255,7 +256,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
 int omap_framebuffer_pin(struct drm_framebuffer *fb)
 {
 	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	int ret, i, n = drm_format_num_planes(fb->pixel_format);
+	int ret, i;
 
 	mutex_lock(&omap_fb->lock);
 
@@ -265,7 +266,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
 		return 0;
 	}
 
-	for (i = 0; i < n; i++) {
+	for (i = 0; i < omap_fb->format->num_planes; i++) {
 		struct plane *plane = &omap_fb->planes[i];
 		ret = omap_gem_get_paddr(plane->bo, &plane->paddr, true);
 		if (ret)
@@ -295,7 +296,7 @@ fail:
 void omap_framebuffer_unpin(struct drm_framebuffer *fb)
 {
 	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	int i, n = drm_format_num_planes(fb->pixel_format);
+	int i;
 
 	mutex_lock(&omap_fb->lock);
 
@@ -306,7 +307,7 @@ void omap_framebuffer_unpin(struct drm_framebuffer *fb)
 		return;
 	}
 
-	for (i = 0; i < n; i++) {
+	for (i = 0; i < omap_fb->format->num_planes; i++) {
 		struct plane *plane = &omap_fb->planes[i];
 		omap_gem_put_paddr(plane->bo);
 		plane->paddr = 0;
@@ -318,8 +319,10 @@ void omap_framebuffer_unpin(struct drm_framebuffer *fb)
 struct drm_gem_object *omap_framebuffer_bo(struct drm_framebuffer *fb, int p)
 {
 	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	if (p >= drm_format_num_planes(fb->pixel_format))
+
+	if (p >= omap_fb->format->num_planes)
 		return NULL;
+
 	return omap_fb->planes[p].bo;
 }
 
@@ -354,12 +357,12 @@ struct drm_connector *omap_framebuffer_get_next_connector(
 void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 {
 	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	int i, n = drm_format_num_planes(fb->pixel_format);
+	int i;
 
 	seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height,
 			(char *)&fb->pixel_format);
 
-	for (i = 0; i < n; i++) {
+	for (i = 0; i < omap_fb->format->num_planes; i++) {
 		struct plane *plane = &omap_fb->planes[i];
 		seq_printf(m, "   %d: offset=%d pitch=%d, obj: ",
 				i, plane->offset, plane->pitch);
@@ -396,7 +399,7 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
 	struct omap_framebuffer *omap_fb = NULL;
 	struct drm_framebuffer *fb = NULL;
 	const struct format *format = NULL;
-	int ret, i, n = drm_format_num_planes(mode_cmd->pixel_format);
+	int ret, i;
 
 	DBG("create framebuffer: dev=%p, mode_cmd=%p (%dx%d@%4.4s)",
 			dev, mode_cmd, mode_cmd->width, mode_cmd->height,
@@ -426,7 +429,7 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
 	omap_fb->format = format;
 	mutex_init(&omap_fb->lock);
 
-	for (i = 0; i < n; i++) {
+	for (i = 0; i < format->num_planes; i++) {
 		struct plane *plane = &omap_fb->planes[i];
 		int size, pitch = mode_cmd->pitches[i];
 
-- 
2.7.3

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux