drm/omap: updates for addfb2 and plane support
cover drm/omap: updates for addfb2 and plane support
From: Rob Clark <[email protected]>
The first patch updates omapdrm for API changes introduced when addfb2 support (for multi-planar fb's) was added (in drm-next). The next patch adds drm plane (overlay) support, with CRTCs using private plane objects to avoid code duplication between the CRTC and plane. (This depends on the "drm: add support for private planes" patch.) The final patch adds support for YUV and multi-planar YUV formats.
This updated patch set rebases on drm-next as of today, and removes an internal helper function in favor of the new drm_format_num_planes() helper. These patches replace the last patchset sent on 15 Dec 2011.
Rob Clark (3):
drm/omap: drm API update: addfb2
drm/omap: add drm_plane support
drm/omap: multiplanar and YUV support
drivers/staging/omapdrm/Makefile | 1 + drivers/staging/omapdrm/omap_crtc.c | 191 +++++--------------- drivers/staging/omapdrm/omap_drv.c | 53 ++++-- drivers/staging/omapdrm/omap_drv.h | 46 ++++- 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 | 329 ++++++++++++++++++++++++++++++++++ drivers/staging/omapdrm/omap_priv.h | 12 +- 9 files changed, 665 insertions(+), 251 deletions(-) create mode 100644 drivers/staging/omapdrm/omap_plane.c
Signature · 1 line
1.7.5.4
PATCH 1/3 drm/omap: drm API update: addfb2
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
@@ -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
Re: [PATCH 1/3] drm/omap: drm API update: addfb2
drivers/staging/omapdrm/omap_fb.c line 46
Quoted 7 lines · Rob Clark
drivers/staging/omapdrm/omap_fb.c +7
-0+static const struct format formats[] = { +/* 16bpp [A]RGB: */ + {OMAP_DSS_COLOR_RGB16 ,DRM_FORMAT_RGB565 , {{2 ,1 }}, false },/* RGB16-565 */ + {OMAP_DSS_COLOR_RGB12U ,DRM_FORMAT_RGBX4444 , {{2 ,1 }}, false },/* RGB12x-4444 */ + {OMAP_DSS_COLOR_RGBX16 ,DRM_FORMAT_XRGB4444 , {{2 ,1 }}, false },/* xRGB12-4444 */ + {OMAP_DSS_COLOR_RGBA16 ,DRM_FORMAT_RGBA4444 , {{2 ,1 }}, false },/* RGBA12-4444 */ + {OMAP_DSS_COLOR_ARGB16 ,DRM_FORMAT_ABGR4444 , {{2 ,1 }}, false },/* ARGB16-4444 */
^^^^^^^^
Should be ARGB4444, no?
BTW I took a quick gander at the format specifications in the OMAP4 TRM and it has a funny bug.
xRGB16-1555 and ARGB16-1555 are listed like this:
31 ... 0
U R1 G1 B1 U R0 B0 G0
A1 R1 G1 B1 A0 R0 B0 G0
So every second pixel has B and G swapped around. That would be some interesting hardware to use :D
It's possible the TRM I had lying around was an old one though and the issue is fixed in later revisions.
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH 1/3] drm/omap: drm API update: addfb2
Quoted 11 lines · Ville Syrjälä
Quoted 7 lines · Rob Clark
+static const struct format formats[] = {
+ /* 16bpp [A]RGB: */
+ {OMAP_DSS_COLOR_RGB16,DRM_FORMAT_RGB565, {{2, 1}}, false }, /* RGB16-565 */
+ {OMAP_DSS_COLOR_RGB12U, DRM_FORMAT_RGBX4444, {{2, 1}}, false }, /* RGB12x-4444 */
+ {OMAP_DSS_COLOR_RGBX16, DRM_FORMAT_XRGB4444, {{2, 1}}, false }, /* xRGB12-4444 */
+ {OMAP_DSS_COLOR_RGBA16, DRM_FORMAT_RGBA4444, {{2, 1}}, false }, /* RGBA12-4444 */
+ {OMAP_DSS_COLOR_ARGB16, DRM_FORMAT_ABGR4444, {{2, 1}}, false }, /* ARGB16-4444 */^^^^^^^^
Should be ARGB4444, no?
yes, you are right.. I got that backwards
Quoted 9 lines
BTW I took a quick gander at the format specifications in the OMAP4 TRM and it has a funny bug.
xRGB16-1555 and ARGB16-1555 are listed like this:
31 ... 0
U R1 G1 B1 U R0 B0 G0
A1 R1 G1 B1 A0 R0 B0 G0
Quoted 5 lines
So every second pixel has B and G swapped around. That would be some interesting hardware to use :D
It's possible the TRM I had lying around was an old one though and the issue is fixed in later revisions.
It is still like this in the version of TRM that I have.. I've never really used those formats, so can't really if that is a documentation bug or just a weird format. Maybe I should remove those from the table too until I have a chance to verify.
BR,
-R
Quoted 7 lines
--
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/3] drm/omap: drm API update: addfb2
Quoted 28 lines · Rob Clark
Quoted 11 lines · Ville Syrjälä
Quoted 7 lines · Rob Clark
+static const struct format formats[] = {
+ /* 16bpp [A]RGB: */
+ {OMAP_DSS_COLOR_RGB16,DRM_FORMAT_RGB565, {{2, 1}}, false }, /* RGB16-565 */
+ {OMAP_DSS_COLOR_RGB12U, DRM_FORMAT_RGBX4444, {{2, 1}}, false }, /* RGB12x-4444 */
+ {OMAP_DSS_COLOR_RGBX16, DRM_FORMAT_XRGB4444, {{2, 1}}, false }, /* xRGB12-4444 */
+ {OMAP_DSS_COLOR_RGBA16, DRM_FORMAT_RGBA4444, {{2, 1}}, false }, /* RGBA12-4444 */
+ {OMAP_DSS_COLOR_ARGB16, DRM_FORMAT_ABGR4444, {{2, 1}}, false }, /* ARGB16-4444 */^^^^^^^^
Should be ARGB4444, no?
yes, you are right.. I got that backwards
Quoted 12 lines
BTW I took a quick gander at the format specifications in the OMAP4 TRM and it has a funny bug.
xRGB16-1555 and ARGB16-1555 are listed like this:
31 ... 0
U R1 G1 B1 U R0 B0 G0
A1 R1 G1 B1 A0 R0 B0 G0So every second pixel has B and G swapped around. That would be some interesting hardware to use :D
Quoted 7 lines
Quoted 2 lines
It's possible the TRM I had lying around was an old one though and the issue is fixed in later revisions.
It is still like this in the version of TRM that I have.. I've never really used those formats, so can't really if that is a documentation bug or just a weird format. Maybe I should remove those from the table too until I have a chance to verify.
I was going to say that I tested them on OMAP3 when I was still @nokia, but now that I checked again OMAP3 doesn't support the 1555 formats. It was the 4444 formats I tested, and even exposed to users via Xv on the N9.
Signature · 3 lines
Ville Syrjälä [email protected] http://www.sci.fi/~syrjala/
Re: [PATCH 1/3] drm/omap: drm API update: addfb2
In reply to Ville SyrjäläQuoted 15 lines · Ville Syrjälä
Quoted 7 lines · Rob Clark
+static const struct format formats[] = {
+ /* 16bpp [A]RGB: */
+ {OMAP_DSS_COLOR_RGB16,DRM_FORMAT_RGB565, {{2, 1}}, false }, /* RGB16-565 */
+ {OMAP_DSS_COLOR_RGB12U, DRM_FORMAT_RGBX4444, {{2, 1}}, false }, /* RGB12x-4444 */
+ {OMAP_DSS_COLOR_RGBX16, DRM_FORMAT_XRGB4444, {{2, 1}}, false }, /* xRGB12-4444 */
+ {OMAP_DSS_COLOR_RGBA16, DRM_FORMAT_RGBA4444, {{2, 1}}, false }, /* RGBA12-4444 */
+ {OMAP_DSS_COLOR_ARGB16, DRM_FORMAT_ABGR4444, {{2, 1}}, false }, /* ARGB16-4444 */^^^^^^^^
Should be ARGB4444, no?
BTW I took a quick gander at the format specifications in the OMAP4 TRM and it has a funny bug.
Quoted 8 lines
xRGB16-1555 and ARGB16-1555 are listed like this:
31 ... 0
U R1 G1 B1 U R0 B0 G0
A1 R1 G1 B1 A0 R0 B0 G0So every second pixel has B and G swapped around. That would be some interesting hardware to use :D
fwiw, I finally had a chance to make a small test, and that is indeed a documentation bug. The format is actually what would be expected for A/xRGB16-1555:
U/A1 R1 G1 B1 U/A1 R0 G0 B0
BR,
-R
Quoted 10 lines
It's possible the TRM I had lying around was an old one though and the issue is fixed in later revisions.
--
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/3 drm/omap: add drm_plane support
In reply to Rob ClarkFrom: 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
@@ -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
@@ -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
@@ -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
PATCH 3/3 drm/omap: multiplanar and YUV support
In reply to Rob ClarkFrom: 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
@@ -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
@@ -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
@@ -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