@@ -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;
}
@@ -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;
};
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@intel.com> --- drivers/gpu/drm/drm_crtc_helper.c | 20 ++++++++++++++++++++ include/drm/drm_crtc.h | 9 +++++++++ 2 files changed, 29 insertions(+)