|
@@ -41,10 +41,12 @@
|
|
|
* exynos specific framebuffer structure.
|
|
|
*
|
|
|
* @fb: drm framebuffer obejct.
|
|
|
+ * @buf_cnt: a buffer count to drm framebuffer.
|
|
|
* @exynos_gem_obj: array of exynos specific gem object containing a gem object.
|
|
|
*/
|
|
|
struct exynos_drm_fb {
|
|
|
struct drm_framebuffer fb;
|
|
|
+ unsigned int buf_cnt;
|
|
|
struct exynos_drm_gem_obj *exynos_gem_obj[MAX_FB_BUFFER];
|
|
|
};
|
|
|
|
|
@@ -101,6 +103,25 @@ static struct drm_framebuffer_funcs exynos_drm_fb_funcs = {
|
|
|
.dirty = exynos_drm_fb_dirty,
|
|
|
};
|
|
|
|
|
|
+void exynos_drm_fb_set_buf_cnt(struct drm_framebuffer *fb,
|
|
|
+ unsigned int cnt)
|
|
|
+{
|
|
|
+ struct exynos_drm_fb *exynos_fb;
|
|
|
+
|
|
|
+ exynos_fb = to_exynos_fb(fb);
|
|
|
+
|
|
|
+ exynos_fb->buf_cnt = cnt;
|
|
|
+}
|
|
|
+
|
|
|
+unsigned int exynos_drm_fb_get_buf_cnt(struct drm_framebuffer *fb)
|
|
|
+{
|
|
|
+ struct exynos_drm_fb *exynos_fb;
|
|
|
+
|
|
|
+ exynos_fb = to_exynos_fb(fb);
|
|
|
+
|
|
|
+ return exynos_fb->buf_cnt;
|
|
|
+}
|
|
|
+
|
|
|
struct drm_framebuffer *
|
|
|
exynos_drm_framebuffer_init(struct drm_device *dev,
|
|
|
struct drm_mode_fb_cmd2 *mode_cmd,
|
|
@@ -127,6 +148,43 @@ exynos_drm_framebuffer_init(struct drm_device *dev,
|
|
|
return &exynos_fb->fb;
|
|
|
}
|
|
|
|
|
|
+static u32 exynos_drm_format_num_buffers(struct drm_mode_fb_cmd2 *mode_cmd)
|
|
|
+{
|
|
|
+ unsigned int cnt = 0;
|
|
|
+
|
|
|
+ if (mode_cmd->pixel_format != DRM_FORMAT_NV12)
|
|
|
+ return drm_format_num_planes(mode_cmd->pixel_format);
|
|
|
+
|
|
|
+ while (cnt != MAX_FB_BUFFER) {
|
|
|
+ if (!mode_cmd->handles[cnt])
|
|
|
+ break;
|
|
|
+ cnt++;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * check if NV12 or NV12M.
|
|
|
+ *
|
|
|
+ * NV12
|
|
|
+ * handles[0] = base1, offsets[0] = 0
|
|
|
+ * handles[1] = base1, offsets[1] = Y_size
|
|
|
+ *
|
|
|
+ * NV12M
|
|
|
+ * handles[0] = base1, offsets[0] = 0
|
|
|
+ * handles[1] = base2, offsets[1] = 0
|
|
|
+ */
|
|
|
+ if (cnt == 2) {
|
|
|
+ /*
|
|
|
+ * in case of NV12 format, offsets[1] is not 0 and
|
|
|
+ * handles[0] is same as handles[1].
|
|
|
+ */
|
|
|
+ if (mode_cmd->offsets[1] &&
|
|
|
+ mode_cmd->handles[0] == mode_cmd->handles[1])
|
|
|
+ cnt = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return cnt;
|
|
|
+}
|
|
|
+
|
|
|
static struct drm_framebuffer *
|
|
|
exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
|
|
|
struct drm_mode_fb_cmd2 *mode_cmd)
|
|
@@ -134,7 +192,6 @@ exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
|
|
|
struct drm_gem_object *obj;
|
|
|
struct drm_framebuffer *fb;
|
|
|
struct exynos_drm_fb *exynos_fb;
|
|
|
- int nr;
|
|
|
int i;
|
|
|
|
|
|
DRM_DEBUG_KMS("%s\n", __FILE__);
|
|
@@ -152,9 +209,11 @@ exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
|
|
|
}
|
|
|
|
|
|
exynos_fb = to_exynos_fb(fb);
|
|
|
- nr = exynos_drm_format_num_buffers(fb->pixel_format);
|
|
|
+ exynos_fb->buf_cnt = exynos_drm_format_num_buffers(mode_cmd);
|
|
|
+
|
|
|
+ DRM_DEBUG_KMS("buf_cnt = %d\n", exynos_fb->buf_cnt);
|
|
|
|
|
|
- for (i = 1; i < nr; i++) {
|
|
|
+ for (i = 1; i < exynos_fb->buf_cnt; i++) {
|
|
|
obj = drm_gem_object_lookup(dev, file_priv,
|
|
|
mode_cmd->handles[i]);
|
|
|
if (!obj) {
|