sna: Add XV_COLORSPACE attribute support for sprite Xv adaptors
PATCH 1/1 sna: Add XV_COLORSPACE attribute support for sprite Xv adaptors
From: Ville Syrjälä <[email protected]>
Use the new "COLOR_ENCODING" plane property to implement the XV_COLORSPACE port attribute for sprite Xv adaptors.
--- src/sna/sna.h | 1 + src/sna/sna_display.c | 148 +++++++++++++++++++++++++++++++++++---------- src/sna/sna_video.h | 3 + src/sna/sna_video_sprite.c | 22 ++++++- 4 files changed, 142 insertions(+), 32 deletions(-)
src/sna/sna.h +1 -0
@@ -634,6 +634,7 @@ static inline void sna_present_cancel_flip(struct sna *sna) { }extern unsigned sna_crtc_count_sprites (xf86CrtcPtr crtc);extern bool sna_crtc_set_sprite_rotation (xf86CrtcPtr crtc,unsigned idx,uint32_t rotation); +extern void sna_crtc_set_sprite_colorspace (xf86CrtcPtr crtc,unsigned idx,int colorspace);extern uint32_t sna_crtc_to_sprite (xf86CrtcPtr crtc,unsigned idx);extern bool sna_crtc_is_transformed (xf86CrtcPtr crtc);
src/sna/sna_display.c +117 -31
174 lines not on this page · raw message
src/sna/sna_video.h +3 -0
@@ -100,6 +100,9 @@ struct sna_video {unsigned color_key_changed;bool has_color_key; +unsigned colorspace; +unsigned colorspace_changed; +/** YUV data buffers */ struct kgem_bo *old_buf[2 ];struct kgem_bo *buf;
src/sna/sna_video_sprite.c +21 -1
@@ -69,11 +69,12 @@ struct local_mode_set_plane {#define MAKE_ATOM (a) MakeAtom(a, sizeof(a) - 1, true) -static Atom xvColorKey, xvAlwaysOnTop, xvSyncToVblank; +static Atom xvColorKey, xvAlwaysOnTop, xvSyncToVblank, xvColorspace;static XvFormatRec formats[] = { {15 }, {16 }, {24 } };static const XvImageRec images[] = {XVIMAGE_YUY2 ,XVIMAGE_UYVY ,XVMC_RGB888 ,XVMC_RGB565 };static const XvAttributeRec attribs[] = { + { XvSettable | XvGettable,0 ,1 , (char *)"XV_COLORSPACE" },/* BT.601, BT.709 */ { XvSettable | XvGettable,0 ,0xffffff , (char *)"XV_COLORKEY" }, { XvSettable | XvGettable,0 ,1 , (char *)"XV_ALWAYS_ON_TOP" }, };
@@ -119,6 +120,10 @@ static int sna_video_sprite_set_attr(ddSetPortAttribute_ARGS) video->color_key = value;RegionEmpty (&video->clip);DBG (("COLORKEY = %ld\n" , (long )value)); + }else if (attribute == xvColorspace) { + video->colorspace_changed = ~0 ; + video->colorspace = value; +DBG (("COLORSPACE = %ld\n" , (long )value)); }else if (attribute == xvSyncToVblank) {DBG (("%s: SYNC_TO_VBLANK: %d -> %d\n" , __FUNCTION__, video->SyncToVblank, !!value));
@@ -140,6 +145,8 @@ static int sna_video_sprite_get_attr(ddGetPortAttribute_ARGS)if (attribute == xvColorKey) *value = video->color_key; +else if (attribute == xvColorspace) + *value = video->colorspace;else if (attribute == xvAlwaysOnTop) *value = video->AlwaysOnTop;else if (attribute == xvSyncToVblank)
@@ -265,6 +272,16 @@ sna_video_sprite_show(struct sna *sna, video->color_key_changed &= ~(1 << pipe); } +if (video->colorspace_changed & (1 << pipe)) { +DBG (("%s: updating colorspace: %x\n" , + __FUNCTION__, video->colorspace)); + +sna_crtc_set_sprite_colorspace (crtc, video->idx, + video->colorspace); + + video->colorspace_changed &= ~(1 << pipe); + } +update_dst_box_to_crtc_coords (sna, crtc, dstBox);if (frame->rotation & (RR_Rotate_90 | RR_Rotate_270)) {int tmp = frame->width;
@@ -769,6 +786,8 @@ void sna_video_sprite_setup(struct sna *sna, ScreenPtr screen) video->alignment =64 ; video->color_key =sna_video_sprite_color_key (sna); video->color_key_changed = ~0 ; + video->colorspace =1 ;/* BT.709 */ + video->colorspace_changed = ~0 ; video->has_color_key = true; video->brightness =-19 ;/* (255/219) * -16 */ video->contrast =75 ;/* 255/219 * 64 */
@@ -789,6 +808,7 @@ void sna_video_sprite_setup(struct sna *sna, ScreenPtr screen) adaptor->base_id = adaptor->pPorts[0 ].id; xvColorKey =MAKE_ATOM ("XV_COLORKEY" ); + xvColorspace =MAKE_ATOM ("XV_COLORSPACE" ); xvAlwaysOnTop =MAKE_ATOM ("XV_ALWAYS_ON_TOP" ); xvSyncToVblank =MAKE_ATOM ("XV_SYNC_TO_VBLANK" );
Signature · 6 lines
2.13.6 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Ville Syrjala (2018-02-14 19:21:08)
Quoted 9 lines
From: Ville Syrjälä <[email protected]>
Use the new "
COLOR_ENCODING" plane property to implement theXV_COLORSPACEport attribute for sprite Xv adaptors.Cc Jyri Sarha <[email protected]>Cc Chris Wilson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>---
src/sna/sna_display.c static const xf86CrtcFuncsRec sna_crtc_funcs = { · line 3405
Quoted 6 lines
src/sna/sna_display.c +6
-0+void sna_crtc_set_sprite_colorspace (xf86CrtcPtr crtc, +unsigned idx,int colorspace) +{ +struct plane *p; + +assert (to_sna_crtc (crtc));
assert(colorspace < ARRAY_SIZE(p->color_encoding.values));
src/sna/sna_display.c static const xf86CrtcFuncsRec sna_crtc_funcs = { · line 3415
Quoted 10 lines
src/sna/sna_display.c +10
-0+ + p =lookup_sprite (to_sna_crtc (crtc), idx); + +if (!p->color_encoding.prop) +return ; + +drmModeObjectSetProperty (to_sna (crtc->scrn)->kgem.fd, + p->id,DRM_MODE_OBJECT_PLANE , + p->color_encoding.prop, + p->color_encoding.values[colorspace]);
Does changing the property trigger an immediate update, or is that deferred until the next SetPlane (or atomic update)?
It makes no difference to this patch, except we might redisplay the image immediately rather than wait for the client? -Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 19 lines · Chris Wilson
Quoting Ville Syrjala (2018-02-14 19:21:08)
Quoted 9 lines
From: Ville Syrjälä <[email protected]>
Use the new "
COLOR_ENCODING" plane property to implement theXV_COLORSPACEport attribute for sprite Xv adaptors.Cc Jyri Sarha <[email protected]>Cc Chris Wilson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>---
src/sna/sna_display.c static const xf86CrtcFuncsRec sna_crtc_funcs = { · line 3405
Quoted 6 lines
src/sna/sna_display.c +6
-0+void sna_crtc_set_sprite_colorspace (xf86CrtcPtr crtc, +unsigned idx,int colorspace) +{ +struct plane *p; + +assert (to_sna_crtc (crtc));
assert(colorspace < ARRAY_SIZE(p->color_encoding.values));
Quoted 13 lines
src/sna/sna_display.c static const xf86CrtcFuncsRec sna_crtc_funcs = { · line 3415
Quoted 10 lines
src/sna/sna_display.c +10
-0+ + p =lookup_sprite (to_sna_crtc (crtc), idx); + +if (!p->color_encoding.prop) +return ; + +drmModeObjectSetProperty (to_sna (crtc->scrn)->kgem.fd, + p->id,DRM_MODE_OBJECT_PLANE , + p->color_encoding.prop, + p->color_encoding.values[colorspace]);Does changing the property trigger an immediate update, or is that deferred until the next SetPlane (or atomic update)?
Legacy setprop so it'll trigger an update. So if the plane is already enabled I suppose we'll get an extra frame of lag here. Same deal as for the colorkey ioctl actually.
I think generally one can assume the the attribute won't be changed very often with the plane already enabled. Generally I'd expect the client to set this up before the first putimage.
Converting this to atomic would avoid that extra lag. But we'd need to convert the colorkey ioctl to properties as well. And the next step after that would tearfree+atomic for making it actually nice :)
Quoted 3 lines
It makes no difference to this patch, except we might redisplay the image immediately rather than wait for the client?
We call this from the putimage hook, so we need the client to actually repaint before anything happens. And since we don't have reputimage manipulating the window/clipping won't update the sprite unless the client repaints (which eg. mplayer won't do when paused unless it gets expose events).
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Ville Syrjälä (2018-02-14 20:06:17)
Quoted 34 lines · Chris Wilson
Quoted 19 lines
Quoting Ville Syrjala (2018-02-14 19:21:08)
Quoted 9 lines
From: Ville Syrjälä <[email protected]>
Use the new "
COLOR_ENCODING" plane property to implement theXV_COLORSPACEport attribute for sprite Xv adaptors.Cc Jyri Sarha <[email protected]>Cc Chris Wilson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>---
src/sna/sna_display.c static const xf86CrtcFuncsRec sna_crtc_funcs = { · line 3405
Quoted 6 lines
src/sna/sna_display.c +6
-0+void sna_crtc_set_sprite_colorspace (xf86CrtcPtr crtc, +unsigned idx,int colorspace) +{ +struct plane *p; + +assert (to_sna_crtc (crtc));
assert(colorspace < ARRAY_SIZE(p->color_encoding.values));Quoted 13 lines
src/sna/sna_display.c static const xf86CrtcFuncsRec sna_crtc_funcs = { · line 3415
Quoted 10 lines
src/sna/sna_display.c +10
-0+ + p =lookup_sprite (to_sna_crtc (crtc), idx); + +if (!p->color_encoding.prop) +return ; + +drmModeObjectSetProperty (to_sna (crtc->scrn)->kgem.fd, + p->id,DRM_MODE_OBJECT_PLANE , + p->color_encoding.prop, + p->color_encoding.values[colorspace]);Does changing the property trigger an immediate update, or is that deferred until the next SetPlane (or atomic update)?
Quoted 7 lines
Legacy setprop so it'll trigger an update. So if the plane is already enabled I suppose we'll get an extra frame of lag here. Same deal as for the colorkey ioctl actually.
I think generally one can assume the the attribute won't be changed very often with the plane already enabled. Generally I'd expect the client to set this up before the first putimage.
Agreed.
Quoted 3 lines
Converting this to atomic would avoid that extra lag. But we'd need to convert the colorkey ioctl to properties as well. And the next step after that would tearfree+atomic for making it actually nice :)
If we wanted nice, we wouldn't start with the X11 protocol! Oh well, if all the shiny new features are going to be hidden being atomic, probably going to have to bite the bullet sooner or later.
Quoted 8 lines
Quoted 2 lines
It makes no difference to this patch, except we might redisplay the image immediately rather than wait for the client?
We call this from the putimage hook, so we need the client to actually repaint before anything happens. And since we don't have reputimage manipulating the window/clipping won't update the sprite unless the client repaints (which eg. mplayer won't do when paused unless it gets expose events).
I knew you were going to mention the lack of ReputImage! :) -Chris
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/1 sna: Add XV_COLORSPACE attribute support for sprite Xv adaptors
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Use the new "COLOR_ENCODING" plane property to implement the XV_COLORSPACE port attribute for sprite Xv adaptors.
v2: assert(colorspace < ARRAY_SIZE) (Chris)
--- src/sna/sna.h | 1 + src/sna/sna_display.c | 149 +++++++++++++++++++++++++++++++++++---------- src/sna/sna_video.h | 3 + src/sna/sna_video_sprite.c | 22 ++++++- 4 files changed, 143 insertions(+), 32 deletions(-)
src/sna/sna.h +1 -0
@@ -634,6 +634,7 @@ static inline void sna_present_cancel_flip(struct sna *sna) { }extern unsigned sna_crtc_count_sprites (xf86CrtcPtr crtc);extern bool sna_crtc_set_sprite_rotation (xf86CrtcPtr crtc,unsigned idx,uint32_t rotation); +extern void sna_crtc_set_sprite_colorspace (xf86CrtcPtr crtc,unsigned idx,int colorspace);extern uint32_t sna_crtc_to_sprite (xf86CrtcPtr crtc,unsigned idx);extern bool sna_crtc_is_transformed (xf86CrtcPtr crtc);
src/sna/sna_display.c +118 -31
175 lines not on this page · raw message
src/sna/sna_video.h +3 -0
@@ -100,6 +100,9 @@ struct sna_video {unsigned color_key_changed;bool has_color_key; +unsigned colorspace; +unsigned colorspace_changed; +/** YUV data buffers */ struct kgem_bo *old_buf[2 ];struct kgem_bo *buf;
src/sna/sna_video_sprite.c +21 -1
@@ -69,11 +69,12 @@ struct local_mode_set_plane {#define MAKE_ATOM (a) MakeAtom(a, sizeof(a) - 1, true) -static Atom xvColorKey, xvAlwaysOnTop, xvSyncToVblank; +static Atom xvColorKey, xvAlwaysOnTop, xvSyncToVblank, xvColorspace;static XvFormatRec formats[] = { {15 }, {16 }, {24 } };static const XvImageRec images[] = {XVIMAGE_YUY2 ,XVIMAGE_UYVY ,XVMC_RGB888 ,XVMC_RGB565 };static const XvAttributeRec attribs[] = { + { XvSettable | XvGettable,0 ,1 , (char *)"XV_COLORSPACE" },/* BT.601, BT.709 */ { XvSettable | XvGettable,0 ,0xffffff , (char *)"XV_COLORKEY" }, { XvSettable | XvGettable,0 ,1 , (char *)"XV_ALWAYS_ON_TOP" }, };
@@ -119,6 +120,10 @@ static int sna_video_sprite_set_attr(ddSetPortAttribute_ARGS) video->color_key = value;RegionEmpty (&video->clip);DBG (("COLORKEY = %ld\n" , (long )value)); + }else if (attribute == xvColorspace) { + video->colorspace_changed = ~0 ; + video->colorspace = value; +DBG (("COLORSPACE = %ld\n" , (long )value)); }else if (attribute == xvSyncToVblank) {DBG (("%s: SYNC_TO_VBLANK: %d -> %d\n" , __FUNCTION__, video->SyncToVblank, !!value));
@@ -140,6 +145,8 @@ static int sna_video_sprite_get_attr(ddGetPortAttribute_ARGS)if (attribute == xvColorKey) *value = video->color_key; +else if (attribute == xvColorspace) + *value = video->colorspace;else if (attribute == xvAlwaysOnTop) *value = video->AlwaysOnTop;else if (attribute == xvSyncToVblank)
@@ -265,6 +272,16 @@ sna_video_sprite_show(struct sna *sna, video->color_key_changed &= ~(1 << pipe); } +if (video->colorspace_changed & (1 << pipe)) { +DBG (("%s: updating colorspace: %x\n" , + __FUNCTION__, video->colorspace)); + +sna_crtc_set_sprite_colorspace (crtc, video->idx, + video->colorspace); + + video->colorspace_changed &= ~(1 << pipe); + } +update_dst_box_to_crtc_coords (sna, crtc, dstBox);if (frame->rotation & (RR_Rotate_90 | RR_Rotate_270)) {int tmp = frame->width;
@@ -769,6 +786,8 @@ void sna_video_sprite_setup(struct sna *sna, ScreenPtr screen) video->alignment =64 ; video->color_key =sna_video_sprite_color_key (sna); video->color_key_changed = ~0 ; + video->colorspace =1 ;/* BT.709 */ + video->colorspace_changed = ~0 ; video->has_color_key = true; video->brightness =-19 ;/* (255/219) * -16 */ video->contrast =75 ;/* 255/219 * 64 */
@@ -789,6 +808,7 @@ void sna_video_sprite_setup(struct sna *sna, ScreenPtr screen) adaptor->base_id = adaptor->pPorts[0 ].id; xvColorKey =MAKE_ATOM ("XV_COLORKEY" ); + xvColorspace =MAKE_ATOM ("XV_COLORSPACE" ); xvAlwaysOnTop =MAKE_ATOM ("XV_ALWAYS_ON_TOP" ); xvSyncToVblank =MAKE_ATOM ("XV_SYNC_TO_VBLANK" );
Signature · 6 lines
2.13.6 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Ville Syrjala (2018-03-02 11:59:18)
Quoted 10 lines
From: Ville Syrjälä <[email protected]>
Use the new "
COLOR_ENCODING" plane property to implement theXV_COLORSPACEport attribute for sprite Xv adaptors.v2:
assert(colorspace < ARRAY_SIZE)(Chris)Cc Jyri Sarha <[email protected]>Cc Chris Wilson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>
Is this (i.e. the kernel implementation is done) ready to land? -Chris
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 6 lines · Chris Wilson
Quoting Ville Syrjala (2018-03-02 11:59:18)
Quoted 5 lines
From: Ville Syrjälä <[email protected]>
Use the new "
COLOR_ENCODING" plane property to implement theXV_COLORSPACEport attribute for sprite Xv adaptors.
Quoted 7 lines
Quoted 5 lines
v2:
assert(colorspace < ARRAY_SIZE)(Chris)Cc Jyri Sarha <[email protected]>Cc Chris Wilson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>Is this (i.e. the kernel implementation is done) ready to land?
No one has complained about the proposed uapi and I have sufficient r-bs, so I'm ready to push the kernel stuff as soon as there's a green light from the user space side.
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Chris Wilson
Reviewed-byQuoting Ville Syrjälä (2018-03-02 12:12:26)
Quoted 13 lines · Chris Wilson
Quoted 12 lines
Quoting Ville Syrjala (2018-03-02 11:59:18)
Quoted 10 lines
From: Ville Syrjälä <[email protected]>
Use the new "
COLOR_ENCODING" plane property to implement theXV_COLORSPACEport attribute for sprite Xv adaptors.v2:
assert(colorspace < ARRAY_SIZE)(Chris)Cc Jyri Sarha <[email protected]>Cc Chris Wilson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>
Quoted 5 lines
Quoted 1 line
Is this (i.e. the kernel implementation is done) ready to land?
No one has complained about the proposed uapi and I have sufficient r-bs, so I'm ready to push the kernel stuff as soon as there's a green light from the user space side.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Chris Wilson (2018-03-02 12:14:07)
Quoted 14 lines
Quoting Ville Syrjälä (2018-03-02 12:12:26)
Quoted 13 lines · Chris Wilson
Quoted 12 lines
Quoting Ville Syrjala (2018-03-02 11:59:18)
Quoted 10 lines
From: Ville Syrjälä <[email protected]>
Use the new "
COLOR_ENCODING" plane property to implement theXV_COLORSPACEport attribute for sprite Xv adaptors.v2:
assert(colorspace < ARRAY_SIZE)(Chris)Cc Jyri Sarha <[email protected]>Cc Chris Wilson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Is this (i.e. the kernel implementation is done) ready to land?
No one has complained about the proposed uapi and I have sufficient r-bs, so I'm ready to push the kernel stuff as soon as there's a green light from the user space side.
Reviewed-by Chris Wilson <[email protected]>
Applied, thanks.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx