[PATCH 09/12] drm: Track the number of buffers that compose a framebuffer

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

 



DRM has supported multiple-buffers fbs since the introduction of ADDFB2.
Let's track the number of buffers in a drm_framebuffer in the common
structure so we can use it in the DRM core.

Signed-off-by: Damien Lespiau <damien.lespiau@xxxxxxxxx>
---
 drivers/gpu/drm/drm_crtc_helper.c | 20 ++++++++++++++++++++
 include/drm/drm_crtc.h            |  9 +++++++++
 2 files changed, 29 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 6a64749..32985c0 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -901,6 +901,25 @@ void drm_helper_connector_dpms(struct drm_connector *connector, int mode)
 }
 EXPORT_SYMBOL(drm_helper_connector_dpms);
 
+static int drm_helper_mode_fb_num_buffers(struct drm_mode_fb_cmd2 *mode_cmd)
+{
+	int count = 0, i, j;
+
+	for (i = 0; i < 4; i++) {
+		if (!mode_cmd->handles[i])
+			continue;
+
+		for (j = 0; j < i; j++)
+			if (mode_cmd->handles[i] == mode_cmd->handles[j])
+				break;
+
+		if (j == i)
+			count++;
+	}
+
+	return count;
+}
+
 int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
 				   struct drm_mode_fb_cmd2 *mode_cmd)
 {
@@ -915,6 +934,7 @@ int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
 	drm_fb_get_bpp_depth(mode_cmd->pixel_format, &fb->depth,
 				    &fb->bits_per_pixel);
 	fb->pixel_format = mode_cmd->pixel_format;
+	fb->num_buffers = drm_helper_mode_fb_num_buffers(mode_cmd);
 
 	return 0;
 }
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index bf242ac..e685baf 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -286,6 +286,15 @@ struct drm_framebuffer {
 	int flags;
 	uint32_t pixel_format; /* fourcc format */
 	struct list_head filp_head;
+	/*
+	 * A framebuffer can be made of several planes (eg. planar YUV
+	 * formats). These planes can either share the same buffer (in which
+	 * case 'offsets' will tell us where they are within that buffer) or
+	 * be in separate buffers (in which case offsets[i] will generally be
+	 * 0). We track in the common DRM code how many different buffers the
+	 * framebuffer consists of.
+	 */
+	int num_buffers;
 	/* if you are using the helper */
 	void *helper_private;
 };
-- 
1.8.3.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://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