Skip to contentSkip to conversation

drm/omap: updates for latest master

PATCH New Rob Clark 1 participant 6 messages Jan 16, 2012 Staging

lore
Share & tools
lore

Rob Clark

author
#0 lore raw

cover drm/omap: updates for latest master

From: Rob Clark <[email protected]>

Now that drm and fbdev (omapdss) next trees have been pulled by Linus, here are the updates to keep omapdrm compiling.

The first four are re-sends of what was sent earlier, and the fifth takes care of some API changes in omapdss contained in the fbdev pull.

Rob Clark (5):
drm/omap: drm API update: make fops struct const drm/omap: drm API update: addfb2 drm/omap: add drm_plane support drm/omap: multiplanar and YUV support drm/omap: updates for DSS fifomerge API changes

 drivers/staging/omapdrm/Makefile     |    1 +
 drivers/staging/omapdrm/omap_crtc.c  |  191 +++++--------------
 drivers/staging/omapdrm/omap_drv.c   |   77 +++++---
 drivers/staging/omapdrm/omap_drv.h   |   52 +++++-
 drivers/staging/omapdrm/omap_fb.c    |  224 ++++++++++++++++------
 drivers/staging/omapdrm/omap_fbdev.c |   55 ++++--
 drivers/staging/omapdrm/omap_gem.c   |    5 +
 drivers/staging/omapdrm/omap_plane.c |  344 ++++++++++++++++++++++++++++++++++
 drivers/staging/omapdrm/omap_priv.h  |   12 +-
 9 files changed, 699 insertions(+), 262 deletions(-)
 create mode 100644 drivers/staging/omapdrm/omap_plane.c
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH 1/5 drm/omap: drm API update: make fops struct const

From: Rob Clark <[email protected]>

Update to reflect changes in:
"Make the per-driver file_operations struct const"

---
 drivers/staging/omapdrm/omap_drv.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)
drivers/staging/omapdrm/omap_drv.c +13 -11
index 602aa2d..4db40f7 100644
@@ -708,6 +708,18 @@ static struct vm_operations_struct omap_gem_vm_ops = {
 	.close = drm_gem_vm_close,
 };
 
+static const struct file_operations omapdriver_fops = {
+		.owner = THIS_MODULE,
+		.open = drm_open,
+		.unlocked_ioctl = drm_ioctl,
+		.release = drm_release,
+		.mmap = omap_gem_mmap,
+		.poll = drm_poll,
+		.fasync = drm_fasync,
+		.read = drm_read,
+		.llseek = noop_llseek,
+};
+
 static struct drm_driver omap_drm_driver = {
 		.driver_features =
 				DRIVER_HAVE_IRQ | DRIVER_MODESET | DRIVER_GEM,
@@ -738,17 +750,7 @@ static struct drm_driver omap_drm_driver = {
 		.dumb_destroy = omap_gem_dumb_destroy,
 		.ioctls = ioctls,
 		.num_ioctls = DRM_OMAP_NUM_IOCTLS,
-		.fops = {
-				.owner = THIS_MODULE,
-				.open = drm_open,
-				.unlocked_ioctl = drm_ioctl,
-				.release = drm_release,
-				.mmap = omap_gem_mmap,
-				.poll = drm_poll,
-				.fasync = drm_fasync,
-				.read = drm_read,
-				.llseek = noop_llseek,
-		},
+		.fops = &omapdriver_fops,
 		.name = DRIVER_NAME,
 		.desc = DRIVER_DESC,
 		.date = DRIVER_DATE,
Signature · 1 line
1.7.5.4
author
#2 lore raw

PATCH 2/5 drm/omap: drm API update: addfb2

In reply to Rob Clark

From: Rob Clark <[email protected]>

Update to reflect changes in:
"drm: add an fb creation ioctl that takes a pixel format v5"

---
 drivers/staging/omapdrm/omap_drv.h   |   30 +++++++++-
 drivers/staging/omapdrm/omap_fb.c    |  103 ++++++++++++++++++++++++++--------
 drivers/staging/omapdrm/omap_fbdev.c |   55 ++++++++++++-------
 3 files changed, 143 insertions(+), 45 deletions(-)
drivers/staging/omapdrm/omap_drv.h +28 -2
index 76c4251..4ad2ae5 100644
@@ -24,6 +24,7 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <drm/drmP.h>
+#include <drm/drm_crtc_helper.h>
 #include "omap_drm.h"
 #include "omap_priv.h"
 
@@ -80,9 +81,9 @@ void omap_connector_flush(struct drm_connector *connector,
 		int x, int y, int w, int h);
 
 struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
-		struct drm_file *file, struct drm_mode_fb_cmd *mode_cmd);
+		struct drm_file *file, struct drm_mode_fb_cmd2 *mode_cmd);
 struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
-		struct drm_mode_fb_cmd *mode_cmd, struct drm_gem_object *bo);
+		struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
 struct drm_gem_object *omap_framebuffer_bo(struct drm_framebuffer *fb);
 int omap_framebuffer_get_buffer(struct drm_framebuffer *fb, int x, int y,
 		void **vaddr, dma_addr_t *paddr, unsigned int *screen_width);
@@ -132,4 +133,29 @@ static inline int align_pitch(int pitch, int width, int bpp)
 	return ALIGN(pitch, 8 * bytespp);
 }
 
+/* should these be made into common util helpers?
+ */
+
+static inline int objects_lookup(struct drm_device *dev,
+		struct drm_file *filp, uint32_t pixel_format,
+		struct drm_gem_object **bos, uint32_t *handles)
+{
+	int i, n = drm_format_num_planes(pixel_format);
+
+	for (i = 0; i < n; i++) {
+		bos[i] = drm_gem_object_lookup(dev, filp, handles[i]);
+		if (!bos[i]) {
+			goto fail;
+		}
+	}
+
+	return 0;
+
+fail:
+	while (--i > 0) {
+		drm_gem_object_unreference_unlocked(bos[i]);
+	}
+	return -ENOENT;
+}
+
 #endif /* __OMAP_DRV_H__ */
drivers/staging/omapdrm/omap_fb.c +80 -23

172 lines not on this page · raw message

drivers/staging/omapdrm/omap_fbdev.c +35 -20

99 lines not on this page · raw message

Signature · 1 line
1.7.5.4
author
#3 lore raw

PATCH 3/5 drm/omap: add drm_plane support

In reply to Rob Clark

From: Rob Clark <[email protected]>

Because framebuffer layer and overlay scanout video pipes are basically thing in OMAP display subsystem (the only difference being that the first video pipe does not support scaling or YUV formats), much of the CRTC code is pulled into the plane implementation, and a private plane object is used by the CRTC object. This avoids code duplication between the plane and CRTC.

---
 drivers/staging/omapdrm/Makefile     |    1 +
 drivers/staging/omapdrm/omap_crtc.c  |  189 +++++----------------
 drivers/staging/omapdrm/omap_drv.c   |   53 ++++---
 drivers/staging/omapdrm/omap_drv.h   |    8 +-
 drivers/staging/omapdrm/omap_plane.c |  308 ++++++++++++++++++++++++++++++++++
 drivers/staging/omapdrm/omap_priv.h  |   12 +-
 6 files changed, 403 insertions(+), 168 deletions(-)
 create mode 100644 drivers/staging/omapdrm/omap_plane.c
drivers/staging/omapdrm/Makefile +1 -0
index 592cf69..d9cdc12 100644
@@ -7,6 +7,7 @@ ccflags-y := -Iinclude/drm -Werror
 omapdrm-y := omap_drv.o \
 	omap_debugfs.o \
 	omap_crtc.o \
+	omap_plane.o \
 	omap_encoder.o \
 	omap_connector.o \
 	omap_fb.o \
drivers/staging/omapdrm/omap_crtc.c +44 -145

284 lines not on this page · raw message

drivers/staging/omapdrm/omap_drv.c +33 -20

89 lines not on this page · raw message

drivers/staging/omapdrm/omap_drv.h +7 -1
index 4ad2ae5..e2b1b55 100644
@@ -42,6 +42,8 @@
 struct omap_drm_private {
 	unsigned int num_crtcs;
 	struct drm_crtc *crtcs[8];
+	unsigned int num_planes;
+	struct drm_plane *planes[8];
 	unsigned int num_encoders;
 	struct drm_encoder *encoders[8];
 	unsigned int num_connectors;
@@ -62,7 +64,11 @@ void omap_fbdev_free(struct drm_device *dev);
 
 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 		struct omap_overlay *ovl, int id);
-struct omap_overlay *omap_crtc_get_overlay(struct drm_crtc *crtc);
+
+struct drm_plane *omap_plane_init(struct drm_device *dev,
+		struct omap_overlay *ovl, unsigned int possible_crtcs,
+		bool priv);
+int omap_plane_dpms(struct drm_plane *plane, int mode);
 
 struct drm_encoder *omap_encoder_init(struct drm_device *dev,
 		struct omap_overlay_manager *mgr);
drivers/staging/omapdrm/omap_plane.c new file +308 -0

308 lines not on this page · raw message

drivers/staging/omapdrm/omap_priv.h +10 -2
index c324709..ef64414 100644
@@ -27,14 +27,22 @@
  * pipes/overlays/CRTCs are used.. if this is not provided, then instead the
  * first CONFIG_DRM_OMAP_NUM_CRTCS are used, and they are each connected to
  * one manager, with priority given to managers that are connected to
- * detected devices.  This should be a good default behavior for most cases,
- * but yet there still might be times when you wish to do something different.
+ * detected devices.  Remaining overlays are used as video planes.  This
+ * should be a good default behavior for most cases, but yet there still
+ * might be times when you wish to do something different.
  */
 struct omap_kms_platform_data {
+	/* overlays to use as CRTCs: */
 	int ovl_cnt;
 	const int *ovl_ids;
+
+	/* overlays to use as video planes: */
+	int pln_cnt;
+	const int *pln_ids;
+
 	int mgr_cnt;
 	const int *mgr_ids;
+
 	int dev_cnt;
 	const char **dev_names;
 };
Signature · 1 line
1.7.5.4
author
#4 lore raw

PATCH 4/5 drm/omap: multiplanar and YUV support

In reply to Rob Clark

From: Rob Clark <[email protected]>

Add support in framebuffer objects for other color formats and multi- planar YUV (NV12). Since this requires changing the API between the plane and fb for getting scanout information (paddr, etc), take advantage of the opportunity and put in place a way to allow fb's to be unpinned when they are not being scanned out. Now, before start of scanout the plane calls omap_framebuffer_pin() which takes care to pin all the backing bo's, then omap_framebuffer_update_scanout() however many times to update the scanout address(es), etc, and then when finished omap_framebuffer_unpin().

---
 drivers/staging/omapdrm/omap_crtc.c  |    2 +-
 drivers/staging/omapdrm/omap_drv.h   |    8 +-
 drivers/staging/omapdrm/omap_fb.c    |  149 +++++++++++++++++++++++-----------
 drivers/staging/omapdrm/omap_gem.c   |    5 +
 drivers/staging/omapdrm/omap_plane.c |   53 +++++++++----
 5 files changed, 149 insertions(+), 68 deletions(-)
drivers/staging/omapdrm/omap_crtc.c +1 -1
index a91c788..3cee04e 100644
@@ -168,7 +168,7 @@ static int omap_crtc_page_flip_locked(struct drm_crtc *crtc,
 	omap_crtc->event = event;
 	crtc->fb = fb;
 
-	omap_gem_op_async(omap_framebuffer_bo(fb), OMAP_GEM_READ,
+	omap_gem_op_async(omap_framebuffer_bo(fb, 0), OMAP_GEM_READ,
 			page_flip_cb, crtc);
 
 	return 0;
drivers/staging/omapdrm/omap_drv.h +5 -3
index e2b1b55..48f6fce 100644
@@ -90,9 +90,11 @@ struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
 		struct drm_file *file, struct drm_mode_fb_cmd2 *mode_cmd);
 struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
 		struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
-struct drm_gem_object *omap_framebuffer_bo(struct drm_framebuffer *fb);
-int omap_framebuffer_get_buffer(struct drm_framebuffer *fb, int x, int y,
-		void **vaddr, dma_addr_t *paddr, unsigned int *screen_width);
+struct drm_gem_object *omap_framebuffer_bo(struct drm_framebuffer *fb, int p);
+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, int x, int y,
+		struct omap_overlay_info *info);
 struct drm_connector *omap_framebuffer_get_next_connector(
 		struct drm_framebuffer *fb, struct drm_connector *from);
 void omap_framebuffer_flush(struct drm_framebuffer *fb,
drivers/staging/omapdrm/omap_fb.c +101 -48

212 lines not on this page · raw message

drivers/staging/omapdrm/omap_gem.c +5 -0
index e0ebd1d..ae1ad35 100644
@@ -1034,6 +1034,11 @@ void omap_gem_free_object(struct drm_gem_object *obj)
 		drm_gem_free_mmap_offset(obj);
 	}
 
+	/* this means the object is still pinned.. which really should
+	 * not happen.  I think..
+	 */
+	WARN_ON(omap_obj->paddr_cnt > 0);
+
 	/* don't free externally allocated backing memory */
 	if (!(omap_obj->flags & OMAP_BO_EXT_MEM)) {
 		if (omap_obj->pages) {
drivers/staging/omapdrm/omap_plane.c +37 -16

92 lines not on this page · raw message

Signature · 1 line
1.7.5.4
author
#5 lore raw

PATCH 5/5 drm/omap: updates for DSS fifomerge API changes

In reply to Rob Clark

From: Rob Clark <[email protected]>

---
 drivers/staging/omapdrm/omap_crtc.c  |    2 +-
 drivers/staging/omapdrm/omap_drv.h   |    6 ++++++
 drivers/staging/omapdrm/omap_plane.c |   33 ++++++++++++++++++++++++---------
 3 files changed, 31 insertions(+), 10 deletions(-)
drivers/staging/omapdrm/omap_crtc.c +1 -1
index 3cee04e..17ca163 100644
@@ -81,7 +81,7 @@ static int omap_crtc_mode_set(struct drm_crtc *crtc,
 	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 	struct drm_plane *plane = omap_crtc->plane;
 
-	return plane->funcs->update_plane(plane, crtc, crtc->fb,
+	return omap_plane_mode_set(plane, crtc, crtc->fb,
 			0, 0, mode->hdisplay, mode->vdisplay,
 			x << 16, y << 16,
 			mode->hdisplay << 16, mode->vdisplay << 16);
drivers/staging/omapdrm/omap_drv.h +6 -0
index 48f6fce..61fe022 100644
@@ -69,6 +69,12 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
 		struct omap_overlay *ovl, unsigned int possible_crtcs,
 		bool priv);
 int omap_plane_dpms(struct drm_plane *plane, int mode);
+int omap_plane_mode_set(struct drm_plane *plane,
+		struct drm_crtc *crtc, struct drm_framebuffer *fb,
+		int crtc_x, int crtc_y,
+		unsigned int crtc_w, unsigned int crtc_h,
+		uint32_t src_x, uint32_t src_y,
+		uint32_t src_w, uint32_t src_h);
 
 struct drm_encoder *omap_encoder_init(struct drm_device *dev,
 		struct omap_overlay_manager *mgr);
drivers/staging/omapdrm/omap_plane.c +24 -9
index 66eed75..9790912 100644
@@ -85,7 +85,7 @@ static int commit(struct drm_plane *plane)
 		}
 	}
 
-	if (info->enabled) {
+	if (ovl->is_enabled(ovl)) {
 		omap_framebuffer_flush(plane->fb, info->pos_x, info->pos_y,
 				info->out_width, info->out_height);
 	}
@@ -115,7 +115,7 @@ static void update_manager(struct drm_plane *plane)
 	}
 
 	if (ovl->manager != mgr) {
-		bool enabled = omap_plane->info.enabled;
+		bool enabled = ovl->is_enabled(ovl);
 
 		/* don't switch things around with enabled overlays: */
 		if (enabled)
@@ -168,7 +168,8 @@ static void update_scanout(struct drm_plane *plane)
 	if (ret) {
 		dev_err(plane->dev->dev,
 			"could not pin fb: %d\n", ret);
-		omap_plane->info.enabled = false;
+		omap_plane_dpms(plane, DRM_MODE_DPMS_OFF);
+		return;
 	}
 
 	omap_framebuffer_update_scanout(plane->fb,
@@ -180,7 +181,7 @@ static void update_scanout(struct drm_plane *plane)
 			info->screen_width);
 }
 
-static int omap_plane_update(struct drm_plane *plane,
+int omap_plane_mode_set(struct drm_plane *plane,
 		struct drm_crtc *crtc, struct drm_framebuffer *fb,
 		int crtc_x, int crtc_y,
 		unsigned int crtc_w, unsigned int crtc_h,
@@ -195,7 +196,6 @@ static int omap_plane_update(struct drm_plane *plane,
 	src_w = src_w >> 16;
 	src_h = src_h >> 16;
 
-	omap_plane->info.enabled = true;
 	omap_plane->info.pos_x = crtc_x;
 	omap_plane->info.pos_y = crtc_y;
 	omap_plane->info.out_width = crtc_w;
@@ -214,11 +214,22 @@ static int omap_plane_update(struct drm_plane *plane,
 
 	update_scanout(plane);
 	update_manager(plane);
-	commit(plane);
 
 	return 0;
 }
 
+static int omap_plane_update(struct drm_plane *plane,
+		struct drm_crtc *crtc, struct drm_framebuffer *fb,
+		int crtc_x, int crtc_y,
+		unsigned int crtc_w, unsigned int crtc_h,
+		uint32_t src_x, uint32_t src_y,
+		uint32_t src_w, uint32_t src_h)
+{
+	omap_plane_mode_set(plane, crtc, fb, crtc_x, crtc_y, crtc_w, crtc_h,
+			src_x, src_y, src_w, src_h);
+	return omap_plane_dpms(plane, DRM_MODE_DPMS_ON);
+}
+
 static int omap_plane_disable(struct drm_plane *plane)
 {
 	return omap_plane_dpms(plane, DRM_MODE_DPMS_OFF);
@@ -236,18 +247,22 @@ static void omap_plane_destroy(struct drm_plane *plane)
 int omap_plane_dpms(struct drm_plane *plane, int mode)
 {
 	struct omap_plane *omap_plane = to_omap_plane(plane);
+	struct omap_overlay *ovl = omap_plane->ovl;
+	int r;
 
 	DBG("%s: %d", omap_plane->ovl->name, mode);
 
 	if (mode == DRM_MODE_DPMS_ON) {
 		update_scanout(plane);
-		omap_plane->info.enabled = true;
+		r = commit(plane);
+		if (!r)
+			r = ovl->enable(ovl);
 	} else {
-		omap_plane->info.enabled = false;
+		r = ovl->disable(ovl);
 		update_pin(plane, NULL);
 	}
 
-	return commit(plane);
+	return r;
 }
 
 static const struct drm_plane_funcs omap_plane_funcs = {
Signature · 1 line
1.7.5.4