From: Ville Syrjälä ville.syrjala@linux.intel.com
Replace the ad-hoc iturbt_709 property with the new standard COLOR_ENCODING property. Compiles, but not tested.
Cc: Daniel Vetter daniel@ffwll.ch Cc: nouveau@lists.freedesktop.org Cc: Ben Skeggs bskeggs@redhat.com Cc: Ilia Mirkin imirkin@alum.mit.edu Signed-off-by: Ville Syrjälä ville.syrjala@linux.intel.com --- drivers/gpu/drm/nouveau/dispnv04/overlay.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/dispnv04/overlay.c b/drivers/gpu/drm/nouveau/dispnv04/overlay.c index c8c2333f24ee..df4358e31075 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/overlay.c +++ b/drivers/gpu/drm/nouveau/dispnv04/overlay.c @@ -46,7 +46,6 @@ struct nouveau_plane { struct drm_property *brightness; struct drm_property *hue; struct drm_property *saturation; - struct drm_property *iturbt_709; } props;
int colorkey; @@ -54,7 +53,7 @@ struct nouveau_plane { int brightness; int hue; int saturation; - int iturbt_709; + enum drm_color_encoding color_encoding;
void (*set_params)(struct nouveau_plane *); }; @@ -166,7 +165,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, if (fb->format->format == DRM_FORMAT_NV12 || fb->format->format == DRM_FORMAT_NV21) format |= NV_PVIDEO_FORMAT_PLANAR; - if (nv_plane->iturbt_709) + if (nv_plane->color_encoding == DRM_COLOR_YCBCR_BT709) format |= NV_PVIDEO_FORMAT_MATRIX_ITURBT709; if (nv_plane->colorkey & (1 << 24)) format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY; @@ -229,7 +228,7 @@ nv10_set_params(struct nouveau_plane *plane) nvif_wr32(dev, NV_PVIDEO_COLOR_KEY, plane->colorkey & 0xffffff);
if (plane->cur) { - if (plane->iturbt_709) + if (plane->color_encoding == DRM_COLOR_YCBCR_BT709) format |= NV_PVIDEO_FORMAT_MATRIX_ITURBT709; if (plane->colorkey & (1 << 24)) format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY; @@ -258,8 +257,8 @@ nv_set_property(struct drm_plane *plane, nv_plane->hue = value; else if (property == nv_plane->props.saturation) nv_plane->saturation = value; - else if (property == nv_plane->props.iturbt_709) - nv_plane->iturbt_709 = value; + else if (property == nv_plane->base.color_encoding_property) + nv_plane->color_encoding = value; else return -EINVAL;
@@ -313,14 +312,11 @@ nv10_overlay_init(struct drm_device *device) device, 0, "hue", 0, 359); plane->props.saturation = drm_property_create_range( device, 0, "saturation", 0, 8192 - 1); - plane->props.iturbt_709 = drm_property_create_range( - device, 0, "iturbt_709", 0, 1); if (!plane->props.colorkey || !plane->props.contrast || !plane->props.brightness || !plane->props.hue || - !plane->props.saturation || - !plane->props.iturbt_709) + !plane->props.saturation) goto cleanup;
plane->colorkey = 0; @@ -343,9 +339,13 @@ nv10_overlay_init(struct drm_device *device) drm_object_attach_property(&plane->base.base, plane->props.saturation, plane->saturation);
- plane->iturbt_709 = 0; - drm_object_attach_property(&plane->base.base, - plane->props.iturbt_709, plane->iturbt_709); + plane->color_encoding = DRM_COLOR_YCBCR_BT601; + drm_plane_create_color_properties(&plane->base, + BIT(DRM_COLOR_YCBCR_BT601) | + BIT(DRM_COLOR_YCBCR_BT709), + BIT(DRM_COLOR_YCBCR_LIMITED_RANGE), + DRM_COLOR_YCBCR_BT601, + DRM_COLOR_YCBCR_LIMITED_RANGE);
plane->set_params = nv10_set_params; nv10_set_params(plane);
On Tue, Feb 20, 2018 at 8:48 AM, Ville Syrjala ville.syrjala@linux.intel.com wrote:
From: Ville Syrjälä ville.syrjala@linux.intel.com
Replace the ad-hoc iturbt_709 property with the new standard COLOR_ENCODING property. Compiles, but not tested.
Cc: Daniel Vetter daniel@ffwll.ch Cc: nouveau@lists.freedesktop.org Cc: Ben Skeggs bskeggs@redhat.com Cc: Ilia Mirkin imirkin@alum.mit.edu Signed-off-by: Ville Syrjälä ville.syrjala@linux.intel.com
s/standarad/standard/ in subject
I'd like the opportunity to test this out on real hardware, but I don't have any pre-NV41 boards plugged in right now. I should be able to attend to it within 7 days. If you don't hear back from me by then, I'd appreciate a ping, as I do let things (hopefully occasionally) slip through.
drivers/gpu/drm/nouveau/dispnv04/overlay.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/dispnv04/overlay.c b/drivers/gpu/drm/nouveau/dispnv04/overlay.c index c8c2333f24ee..df4358e31075 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/overlay.c +++ b/drivers/gpu/drm/nouveau/dispnv04/overlay.c @@ -46,7 +46,6 @@ struct nouveau_plane { struct drm_property *brightness; struct drm_property *hue; struct drm_property *saturation;
struct drm_property *iturbt_709; } props; int colorkey;
@@ -54,7 +53,7 @@ struct nouveau_plane { int brightness; int hue; int saturation;
int iturbt_709;
enum drm_color_encoding color_encoding; void (*set_params)(struct nouveau_plane *);
}; @@ -166,7 +165,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, if (fb->format->format == DRM_FORMAT_NV12 || fb->format->format == DRM_FORMAT_NV21) format |= NV_PVIDEO_FORMAT_PLANAR;
if (nv_plane->iturbt_709)
if (nv_plane->color_encoding == DRM_COLOR_YCBCR_BT709) format |= NV_PVIDEO_FORMAT_MATRIX_ITURBT709; if (nv_plane->colorkey & (1 << 24)) format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY;
@@ -229,7 +228,7 @@ nv10_set_params(struct nouveau_plane *plane) nvif_wr32(dev, NV_PVIDEO_COLOR_KEY, plane->colorkey & 0xffffff);
if (plane->cur) {
if (plane->iturbt_709)
if (plane->color_encoding == DRM_COLOR_YCBCR_BT709) format |= NV_PVIDEO_FORMAT_MATRIX_ITURBT709; if (plane->colorkey & (1 << 24)) format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY;
@@ -258,8 +257,8 @@ nv_set_property(struct drm_plane *plane, nv_plane->hue = value; else if (property == nv_plane->props.saturation) nv_plane->saturation = value;
else if (property == nv_plane->props.iturbt_709)
nv_plane->iturbt_709 = value;
else if (property == nv_plane->base.color_encoding_property)
nv_plane->color_encoding = value; else return -EINVAL;
@@ -313,14 +312,11 @@ nv10_overlay_init(struct drm_device *device) device, 0, "hue", 0, 359); plane->props.saturation = drm_property_create_range( device, 0, "saturation", 0, 8192 - 1);
plane->props.iturbt_709 = drm_property_create_range(
device, 0, "iturbt_709", 0, 1); if (!plane->props.colorkey || !plane->props.contrast || !plane->props.brightness || !plane->props.hue ||
!plane->props.saturation ||
!plane->props.iturbt_709)
!plane->props.saturation) goto cleanup; plane->colorkey = 0;
@@ -343,9 +339,13 @@ nv10_overlay_init(struct drm_device *device) drm_object_attach_property(&plane->base.base, plane->props.saturation, plane->saturation);
plane->iturbt_709 = 0;
drm_object_attach_property(&plane->base.base,
plane->props.iturbt_709, plane->iturbt_709);
plane->color_encoding = DRM_COLOR_YCBCR_BT601;
drm_plane_create_color_properties(&plane->base,
BIT(DRM_COLOR_YCBCR_BT601) |
BIT(DRM_COLOR_YCBCR_BT709),
BIT(DRM_COLOR_YCBCR_LIMITED_RANGE),
DRM_COLOR_YCBCR_BT601,
DRM_COLOR_YCBCR_LIMITED_RANGE); plane->set_params = nv10_set_params; nv10_set_params(plane);
-- 2.13.6
On Tue, Feb 20, 2018 at 9:25 AM, Ilia Mirkin imirkin@alum.mit.edu wrote:
On Tue, Feb 20, 2018 at 8:48 AM, Ville Syrjala ville.syrjala@linux.intel.com wrote:
From: Ville Syrjälä ville.syrjala@linux.intel.com
Replace the ad-hoc iturbt_709 property with the new standard COLOR_ENCODING property. Compiles, but not tested.
Cc: Daniel Vetter daniel@ffwll.ch Cc: nouveau@lists.freedesktop.org Cc: Ben Skeggs bskeggs@redhat.com Cc: Ilia Mirkin imirkin@alum.mit.edu Signed-off-by: Ville Syrjälä ville.syrjala@linux.intel.com
s/standarad/standard/ in subject
I'd like the opportunity to test this out on real hardware, but I don't have any pre-NV41 boards plugged in right now. I should be able to attend to it within 7 days. If you don't hear back from me by then, I'd appreciate a ping, as I do let things (hopefully occasionally) slip through.
Tested this out on a NV34. Seems to work - at least the green SMPTE bar looks different in the two different modes (had to hack modetest to use the SMPTE pattern on planes).
I do wonder about the new color range property... that's more of a connector thing than a plane thing no? Presumably over S-Video it's a partial range, and over VGA it's full? I'd flip it to always full here tbh. (Or just not provide it at all.)
Anyways, with the subject typo(s! noticed ENCODNIG -> ENCODING just now) fixed, this is
Reviewed-by: Ilia Mirkin imirkin@alum.mit.edu
On Tue, Feb 27, 2018 at 12:54:47AM -0500, Ilia Mirkin wrote:
On Tue, Feb 20, 2018 at 9:25 AM, Ilia Mirkin imirkin@alum.mit.edu wrote:
On Tue, Feb 20, 2018 at 8:48 AM, Ville Syrjala ville.syrjala@linux.intel.com wrote:
From: Ville Syrjälä ville.syrjala@linux.intel.com
Replace the ad-hoc iturbt_709 property with the new standard COLOR_ENCODING property. Compiles, but not tested.
Cc: Daniel Vetter daniel@ffwll.ch Cc: nouveau@lists.freedesktop.org Cc: Ben Skeggs bskeggs@redhat.com Cc: Ilia Mirkin imirkin@alum.mit.edu Signed-off-by: Ville Syrjälä ville.syrjala@linux.intel.com
s/standarad/standard/ in subject
I'd like the opportunity to test this out on real hardware, but I don't have any pre-NV41 boards plugged in right now. I should be able to attend to it within 7 days. If you don't hear back from me by then, I'd appreciate a ping, as I do let things (hopefully occasionally) slip through.
Tested this out on a NV34. Seems to work - at least the green SMPTE bar looks different in the two different modes (had to hack modetest to use the SMPTE pattern on planes).
I do wonder about the new color range property... that's more of a connector thing than a plane thing no? Presumably over S-Video it's a partial range, and over VGA it's full? I'd flip it to always full here tbh. (Or just not provide it at all.)
No, this property is just about the range of the input data. Full range YCbCr isn't exaclty common so you'd rarely need this. JPEG uses full range I believe.
Anyways, with the subject typo(s! noticed ENCODNIG -> ENCODING just now) fixed, this is
Reviewed-by: Ilia Mirkin imirkin@alum.mit.edu
Cool. Thanks.
On Tue, Feb 27, 2018 at 10:49:39AM +0200, Ville Syrjälä wrote:
On Tue, Feb 27, 2018 at 12:54:47AM -0500, Ilia Mirkin wrote:
On Tue, Feb 20, 2018 at 9:25 AM, Ilia Mirkin imirkin@alum.mit.edu wrote:
On Tue, Feb 20, 2018 at 8:48 AM, Ville Syrjala ville.syrjala@linux.intel.com wrote:
From: Ville Syrjälä ville.syrjala@linux.intel.com
Replace the ad-hoc iturbt_709 property with the new standard COLOR_ENCODING property. Compiles, but not tested.
Cc: Daniel Vetter daniel@ffwll.ch Cc: nouveau@lists.freedesktop.org Cc: Ben Skeggs bskeggs@redhat.com Cc: Ilia Mirkin imirkin@alum.mit.edu Signed-off-by: Ville Syrjälä ville.syrjala@linux.intel.com
s/standarad/standard/ in subject
I'd like the opportunity to test this out on real hardware, but I don't have any pre-NV41 boards plugged in right now. I should be able to attend to it within 7 days. If you don't hear back from me by then, I'd appreciate a ping, as I do let things (hopefully occasionally) slip through.
Tested this out on a NV34. Seems to work - at least the green SMPTE bar looks different in the two different modes (had to hack modetest to use the SMPTE pattern on planes).
I do wonder about the new color range property... that's more of a connector thing than a plane thing no? Presumably over S-Video it's a partial range, and over VGA it's full? I'd flip it to always full here tbh. (Or just not provide it at all.)
No, this property is just about the range of the input data. Full range YCbCr isn't exaclty common so you'd rarely need this. JPEG uses full range I believe.
Anyways, with the subject typo(s! noticed ENCODNIG -> ENCODING just now) fixed, this is
Reviewed-by: Ilia Mirkin imirkin@alum.mit.edu
Cool. Thanks.
Pushed to drm-misc-next with Ben's ack.
17:27 <imirkin_> <imirkin_> friendly reminder about https://patchwork.freedesktop.org/patch/205620/ -- ville was wondering whether you'd take it, or if he should push via drm-misc. 17:27 <imirkin_> <skeggsb> ack, i'd say ville should take it in drm-misc for now
Hi Ville,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on drm/drm-next] [also build test ERROR on v4.16-rc2 next-20180220] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Ville-Syrjala/drm-nouveau-Replace-t... base: git://people.freedesktop.org/~airlied/linux.git drm-next config: i386-randconfig-a1-201807 (attached as .config) compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4 reproduce: # save the attached .config to linux build tree make ARCH=i386
All errors (new ones prefixed by >>):
drivers/gpu/drm/nouveau/dispnv04/overlay.c:56:26: error: field 'color_encoding' has incomplete type enum drm_color_encoding color_encoding; ^ drivers/gpu/drm/nouveau/dispnv04/overlay.c: In function 'nv10_update_plane': drivers/gpu/drm/nouveau/dispnv04/overlay.c:168:34: error: 'DRM_COLOR_YCBCR_BT709' undeclared (first use in this function) if (nv_plane->color_encoding == DRM_COLOR_YCBCR_BT709) ^ drivers/gpu/drm/nouveau/dispnv04/overlay.c:168:34: note: each undeclared identifier is reported only once for each function it appears in drivers/gpu/drm/nouveau/dispnv04/overlay.c: In function 'nv10_set_params': drivers/gpu/drm/nouveau/dispnv04/overlay.c:231:32: error: 'DRM_COLOR_YCBCR_BT709' undeclared (first use in this function) if (plane->color_encoding == DRM_COLOR_YCBCR_BT709) ^ drivers/gpu/drm/nouveau/dispnv04/overlay.c: In function 'nv_set_property':
drivers/gpu/drm/nouveau/dispnv04/overlay.c:260:37: error: 'struct drm_plane' has no member named 'color_encoding_property'
else if (property == nv_plane->base.color_encoding_property) ^ drivers/gpu/drm/nouveau/dispnv04/overlay.c: In function 'nv10_overlay_init': drivers/gpu/drm/nouveau/dispnv04/overlay.c:342:26: error: 'DRM_COLOR_YCBCR_BT601' undeclared (first use in this function) plane->color_encoding = DRM_COLOR_YCBCR_BT601; ^
drivers/gpu/drm/nouveau/dispnv04/overlay.c:343:2: error: implicit declaration of function 'drm_plane_create_color_properties' [-Werror=implicit-function-declaration]
drm_plane_create_color_properties(&plane->base, ^ In file included from include/linux/kernel.h:11:0, from include/linux/list.h:9, from include/linux/agp_backend.h:33, from include/drm/drmP.h:35, from drivers/gpu/drm/nouveau/dispnv04/overlay.c:26: drivers/gpu/drm/nouveau/dispnv04/overlay.c:345:12: error: 'DRM_COLOR_YCBCR_BT709' undeclared (first use in this function) BIT(DRM_COLOR_YCBCR_BT709), ^ include/linux/bitops.h:7:28: note: in definition of macro 'BIT' #define BIT(nr) (1UL << (nr)) ^
drivers/gpu/drm/nouveau/dispnv04/overlay.c:346:12: error: 'DRM_COLOR_YCBCR_LIMITED_RANGE' undeclared (first use in this function)
BIT(DRM_COLOR_YCBCR_LIMITED_RANGE), ^ include/linux/bitops.h:7:28: note: in definition of macro 'BIT' #define BIT(nr) (1UL << (nr)) ^ cc1: some warnings being treated as errors
vim +260 drivers/gpu/drm/nouveau/dispnv04/overlay.c
111 112 static int 113 nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, 114 struct drm_framebuffer *fb, int crtc_x, int crtc_y, 115 unsigned int crtc_w, unsigned int crtc_h, 116 uint32_t src_x, uint32_t src_y, 117 uint32_t src_w, uint32_t src_h, 118 struct drm_modeset_acquire_ctx *ctx) 119 { 120 struct nouveau_drm *drm = nouveau_drm(plane->dev); 121 struct nvif_object *dev = &drm->client.device.object; 122 struct nouveau_plane *nv_plane = 123 container_of(plane, struct nouveau_plane, base); 124 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb); 125 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 126 struct nouveau_bo *cur = nv_plane->cur; 127 bool flip = nv_plane->flip; 128 int soff = NV_PCRTC0_SIZE * nv_crtc->index; 129 int soff2 = NV_PCRTC0_SIZE * !nv_crtc->index; 130 unsigned shift = drm->client.device.info.chipset >= 0x30 ? 1 : 3; 131 unsigned format = 0; 132 int ret; 133 134 /* Source parameters given in 16.16 fixed point, ignore fractional. */ 135 src_x >>= 16; 136 src_y >>= 16; 137 src_w >>= 16; 138 src_h >>= 16; 139 140 ret = verify_scaling(fb, shift, 0, 0, src_w, src_h, crtc_w, crtc_h); 141 if (ret) 142 return ret; 143 144 ret = nouveau_bo_pin(nv_fb->nvbo, TTM_PL_FLAG_VRAM, false); 145 if (ret) 146 return ret; 147 148 nv_plane->cur = nv_fb->nvbo; 149 150 nvif_mask(dev, NV_PCRTC_ENGINE_CTRL + soff, NV_CRTC_FSEL_OVERLAY, NV_CRTC_FSEL_OVERLAY); 151 nvif_mask(dev, NV_PCRTC_ENGINE_CTRL + soff2, NV_CRTC_FSEL_OVERLAY, 0); 152 153 nvif_wr32(dev, NV_PVIDEO_BASE(flip), 0); 154 nvif_wr32(dev, NV_PVIDEO_OFFSET_BUFF(flip), nv_fb->nvbo->bo.offset); 155 nvif_wr32(dev, NV_PVIDEO_SIZE_IN(flip), src_h << 16 | src_w); 156 nvif_wr32(dev, NV_PVIDEO_POINT_IN(flip), src_y << 16 | src_x); 157 nvif_wr32(dev, NV_PVIDEO_DS_DX(flip), (src_w << 20) / crtc_w); 158 nvif_wr32(dev, NV_PVIDEO_DT_DY(flip), (src_h << 20) / crtc_h); 159 nvif_wr32(dev, NV_PVIDEO_POINT_OUT(flip), crtc_y << 16 | crtc_x); 160 nvif_wr32(dev, NV_PVIDEO_SIZE_OUT(flip), crtc_h << 16 | crtc_w); 161 162 if (fb->format->format == DRM_FORMAT_YUYV || 163 fb->format->format == DRM_FORMAT_NV12) 164 format |= NV_PVIDEO_FORMAT_COLOR_LE_CR8YB8CB8YA8; 165 if (fb->format->format == DRM_FORMAT_NV12 || 166 fb->format->format == DRM_FORMAT_NV21) 167 format |= NV_PVIDEO_FORMAT_PLANAR;
168 if (nv_plane->color_encoding == DRM_COLOR_YCBCR_BT709)
169 format |= NV_PVIDEO_FORMAT_MATRIX_ITURBT709; 170 if (nv_plane->colorkey & (1 << 24)) 171 format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY; 172 173 if (format & NV_PVIDEO_FORMAT_PLANAR) { 174 nvif_wr32(dev, NV_PVIDEO_UVPLANE_BASE(flip), 0); 175 nvif_wr32(dev, NV_PVIDEO_UVPLANE_OFFSET_BUFF(flip), 176 nv_fb->nvbo->bo.offset + fb->offsets[1]); 177 } 178 nvif_wr32(dev, NV_PVIDEO_FORMAT(flip), format | fb->pitches[0]); 179 nvif_wr32(dev, NV_PVIDEO_STOP, 0); 180 /* TODO: wait for vblank? */ 181 nvif_wr32(dev, NV_PVIDEO_BUFFER, flip ? 0x10 : 0x1); 182 nv_plane->flip = !flip; 183 184 if (cur) 185 nouveau_bo_unpin(cur); 186 187 return 0; 188 } 189 190 static int 191 nv10_disable_plane(struct drm_plane *plane, 192 struct drm_modeset_acquire_ctx *ctx) 193 { 194 struct nvif_object *dev = &nouveau_drm(plane->dev)->client.device.object; 195 struct nouveau_plane *nv_plane = 196 container_of(plane, struct nouveau_plane, base); 197 198 nvif_wr32(dev, NV_PVIDEO_STOP, 1); 199 if (nv_plane->cur) { 200 nouveau_bo_unpin(nv_plane->cur); 201 nv_plane->cur = NULL; 202 } 203 204 return 0; 205 } 206 207 static void 208 nv_destroy_plane(struct drm_plane *plane) 209 { 210 drm_plane_force_disable(plane); 211 drm_plane_cleanup(plane); 212 kfree(plane); 213 } 214 215 static void 216 nv10_set_params(struct nouveau_plane *plane) 217 { 218 struct nvif_object *dev = &nouveau_drm(plane->base.dev)->client.device.object; 219 u32 luma = (plane->brightness - 512) << 16 | plane->contrast; 220 u32 chroma = ((sin_mul(plane->hue, plane->saturation) & 0xffff) << 16) | 221 (cos_mul(plane->hue, plane->saturation) & 0xffff); 222 u32 format = 0; 223 224 nvif_wr32(dev, NV_PVIDEO_LUMINANCE(0), luma); 225 nvif_wr32(dev, NV_PVIDEO_LUMINANCE(1), luma); 226 nvif_wr32(dev, NV_PVIDEO_CHROMINANCE(0), chroma); 227 nvif_wr32(dev, NV_PVIDEO_CHROMINANCE(1), chroma); 228 nvif_wr32(dev, NV_PVIDEO_COLOR_KEY, plane->colorkey & 0xffffff); 229 230 if (plane->cur) { 231 if (plane->color_encoding == DRM_COLOR_YCBCR_BT709) 232 format |= NV_PVIDEO_FORMAT_MATRIX_ITURBT709; 233 if (plane->colorkey & (1 << 24)) 234 format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY; 235 nvif_mask(dev, NV_PVIDEO_FORMAT(plane->flip), 236 NV_PVIDEO_FORMAT_MATRIX_ITURBT709 | 237 NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY, 238 format); 239 } 240 } 241 242 static int 243 nv_set_property(struct drm_plane *plane, 244 struct drm_property *property, 245 uint64_t value) 246 { 247 struct nouveau_plane *nv_plane = 248 container_of(plane, struct nouveau_plane, base); 249 250 if (property == nv_plane->props.colorkey) 251 nv_plane->colorkey = value; 252 else if (property == nv_plane->props.contrast) 253 nv_plane->contrast = value; 254 else if (property == nv_plane->props.brightness) 255 nv_plane->brightness = value; 256 else if (property == nv_plane->props.hue) 257 nv_plane->hue = value; 258 else if (property == nv_plane->props.saturation) 259 nv_plane->saturation = value;
260 else if (property == nv_plane->base.color_encoding_property)
261 nv_plane->color_encoding = value; 262 else 263 return -EINVAL; 264 265 if (nv_plane->set_params) 266 nv_plane->set_params(nv_plane); 267 return 0; 268 } 269 270 static const struct drm_plane_funcs nv10_plane_funcs = { 271 .update_plane = nv10_update_plane, 272 .disable_plane = nv10_disable_plane, 273 .set_property = nv_set_property, 274 .destroy = nv_destroy_plane, 275 }; 276 277 static void 278 nv10_overlay_init(struct drm_device *device) 279 { 280 struct nouveau_drm *drm = nouveau_drm(device); 281 struct nouveau_plane *plane = kzalloc(sizeof(struct nouveau_plane), GFP_KERNEL); 282 unsigned int num_formats = ARRAY_SIZE(formats); 283 int ret; 284 285 if (!plane) 286 return; 287 288 switch (drm->client.device.info.chipset) { 289 case 0x10: 290 case 0x11: 291 case 0x15: 292 case 0x1a: 293 case 0x20: 294 num_formats = 2; 295 break; 296 } 297 298 ret = drm_plane_init(device, &plane->base, 3 /* both crtc's */, 299 &nv10_plane_funcs, 300 formats, num_formats, false); 301 if (ret) 302 goto err; 303 304 /* Set up the plane properties */ 305 plane->props.colorkey = drm_property_create_range( 306 device, 0, "colorkey", 0, 0x01ffffff); 307 plane->props.contrast = drm_property_create_range( 308 device, 0, "contrast", 0, 8192 - 1); 309 plane->props.brightness = drm_property_create_range( 310 device, 0, "brightness", 0, 1024); 311 plane->props.hue = drm_property_create_range( 312 device, 0, "hue", 0, 359); 313 plane->props.saturation = drm_property_create_range( 314 device, 0, "saturation", 0, 8192 - 1); 315 if (!plane->props.colorkey || 316 !plane->props.contrast || 317 !plane->props.brightness || 318 !plane->props.hue || 319 !plane->props.saturation) 320 goto cleanup; 321 322 plane->colorkey = 0; 323 drm_object_attach_property(&plane->base.base, 324 plane->props.colorkey, plane->colorkey); 325 326 plane->contrast = 0x1000; 327 drm_object_attach_property(&plane->base.base, 328 plane->props.contrast, plane->contrast); 329 330 plane->brightness = 512; 331 drm_object_attach_property(&plane->base.base, 332 plane->props.brightness, plane->brightness); 333 334 plane->hue = 0; 335 drm_object_attach_property(&plane->base.base, 336 plane->props.hue, plane->hue); 337 338 plane->saturation = 0x1000; 339 drm_object_attach_property(&plane->base.base, 340 plane->props.saturation, plane->saturation); 341 342 plane->color_encoding = DRM_COLOR_YCBCR_BT601;
343 drm_plane_create_color_properties(&plane->base,
344 BIT(DRM_COLOR_YCBCR_BT601) | 345 BIT(DRM_COLOR_YCBCR_BT709),
346 BIT(DRM_COLOR_YCBCR_LIMITED_RANGE),
347 DRM_COLOR_YCBCR_BT601, 348 DRM_COLOR_YCBCR_LIMITED_RANGE); 349 350 plane->set_params = nv10_set_params; 351 nv10_set_params(plane); 352 drm_plane_force_disable(&plane->base); 353 return; 354 cleanup: 355 drm_plane_cleanup(&plane->base); 356 err: 357 kfree(plane); 358 NV_ERROR(drm, "Failed to create plane\n"); 359 } 360
--- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi Ville,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on drm/drm-next] [also build test ERROR on v4.16-rc2 next-20180220] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Ville-Syrjala/drm-nouveau-Replace-t... base: git://people.freedesktop.org/~airlied/linux.git drm-next config: x86_64-allyesdebian (attached as .config) compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64
All errors (new ones prefixed by >>):
drivers/gpu/drm/nouveau/dispnv04/overlay.c:56:26: error: field 'color_encoding' has incomplete type
enum drm_color_encoding color_encoding; ^~~~~~~~~~~~~~ drivers/gpu/drm/nouveau/dispnv04/overlay.c: In function 'nv10_update_plane':
drivers/gpu/drm/nouveau/dispnv04/overlay.c:168:34: error: 'DRM_COLOR_YCBCR_BT709' undeclared (first use in this function)
if (nv_plane->color_encoding == DRM_COLOR_YCBCR_BT709) ^~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/nouveau/dispnv04/overlay.c:168:34: note: each undeclared identifier is reported only once for each function it appears in drivers/gpu/drm/nouveau/dispnv04/overlay.c: In function 'nv10_set_params': drivers/gpu/drm/nouveau/dispnv04/overlay.c:231:32: error: 'DRM_COLOR_YCBCR_BT709' undeclared (first use in this function) if (plane->color_encoding == DRM_COLOR_YCBCR_BT709) ^~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/nouveau/dispnv04/overlay.c: In function 'nv_set_property':
drivers/gpu/drm/nouveau/dispnv04/overlay.c:260:38: error: 'struct drm_plane' has no member named 'color_encoding_property'; did you mean 'rotation_property'?
else if (property == nv_plane->base.color_encoding_property) ^~~~~~~~~~~~~~~~~~~~~~~ rotation_property drivers/gpu/drm/nouveau/dispnv04/overlay.c: In function 'nv10_overlay_init':
drivers/gpu/drm/nouveau/dispnv04/overlay.c:342:26: error: 'DRM_COLOR_YCBCR_BT601' undeclared (first use in this function)
plane->color_encoding = DRM_COLOR_YCBCR_BT601; ^~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/nouveau/dispnv04/overlay.c:343:2: error: implicit declaration of function 'drm_plane_create_color_properties'; did you mean 'drm_plane_create_zpos_property'? [-Werror=implicit-function-declaration]
drm_plane_create_color_properties(&plane->base, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drm_plane_create_zpos_property In file included from include/linux/kernel.h:11:0, from include/linux/list.h:9, from include/linux/agp_backend.h:33, from include/drm/drmP.h:35, from drivers/gpu/drm/nouveau/dispnv04/overlay.c:26:
drivers/gpu/drm/nouveau/dispnv04/overlay.c:345:12: error: 'DRM_COLOR_YCBCR_BT709' undeclared (first use in this function); did you mean 'DRM_COLOR_YCBCR_BT601'?
BIT(DRM_COLOR_YCBCR_BT709), ^ include/linux/bitops.h:7:28: note: in definition of macro 'BIT' #define BIT(nr) (1UL << (nr)) ^~
drivers/gpu/drm/nouveau/dispnv04/overlay.c:346:12: error: 'DRM_COLOR_YCBCR_LIMITED_RANGE' undeclared (first use in this function); did you mean 'DRM_COLOR_YCBCR_BT709'?
BIT(DRM_COLOR_YCBCR_LIMITED_RANGE), ^ include/linux/bitops.h:7:28: note: in definition of macro 'BIT' #define BIT(nr) (1UL << (nr)) ^~ cc1: some warnings being treated as errors
vim +/color_encoding +56 drivers/gpu/drm/nouveau/dispnv04/overlay.c
26 #include <drm/drmP.h>
27 #include <drm/drm_crtc.h> 28 #include <drm/drm_fourcc.h> 29 30 #include "nouveau_drv.h" 31 32 #include "nouveau_bo.h" 33 #include "nouveau_connector.h" 34 #include "nouveau_display.h" 35 #include "nvreg.h" 36 #include "disp.h" 37 38 struct nouveau_plane { 39 struct drm_plane base; 40 bool flip; 41 struct nouveau_bo *cur; 42 43 struct { 44 struct drm_property *colorkey; 45 struct drm_property *contrast; 46 struct drm_property *brightness; 47 struct drm_property *hue; 48 struct drm_property *saturation; 49 } props; 50 51 int colorkey; 52 int contrast; 53 int brightness; 54 int hue; 55 int saturation;
56 enum drm_color_encoding color_encoding;
57 58 void (*set_params)(struct nouveau_plane *); 59 }; 60 61 static uint32_t formats[] = { 62 DRM_FORMAT_YUYV, 63 DRM_FORMAT_UYVY, 64 DRM_FORMAT_NV12, 65 DRM_FORMAT_NV21, 66 }; 67 68 /* Sine can be approximated with 69 * http://en.wikipedia.org/wiki/Bhaskara_I%27s_sine_approximation_formula 70 * sin(x degrees) ~= 4 x (180 - x) / (40500 - x (180 - x) ) 71 * Note that this only works for the range [0, 180]. 72 * Also note that sin(x) == -sin(x - 180) 73 */ 74 static inline int 75 sin_mul(int degrees, int factor) 76 { 77 if (degrees > 180) { 78 degrees -= 180; 79 factor *= -1; 80 } 81 return factor * 4 * degrees * (180 - degrees) / 82 (40500 - degrees * (180 - degrees)); 83 } 84 85 /* cos(x) = sin(x + 90) */ 86 static inline int 87 cos_mul(int degrees, int factor) 88 { 89 return sin_mul((degrees + 90) % 360, factor); 90 } 91 92 static int 93 verify_scaling(const struct drm_framebuffer *fb, uint8_t shift, 94 uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h, 95 uint32_t crtc_w, uint32_t crtc_h) 96 { 97 if (crtc_w < (src_w >> shift) || crtc_h < (src_h >> shift)) { 98 DRM_DEBUG_KMS("Unsuitable framebuffer scaling: %dx%d -> %dx%d\n", 99 src_w, src_h, crtc_w, crtc_h); 100 return -ERANGE; 101 } 102 103 if (src_x != 0 || src_y != 0) { 104 DRM_DEBUG_KMS("Unsuitable framebuffer offset: %d,%d\n", 105 src_x, src_y); 106 return -ERANGE; 107 } 108 109 return 0; 110 } 111 112 static int 113 nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, 114 struct drm_framebuffer *fb, int crtc_x, int crtc_y, 115 unsigned int crtc_w, unsigned int crtc_h, 116 uint32_t src_x, uint32_t src_y, 117 uint32_t src_w, uint32_t src_h, 118 struct drm_modeset_acquire_ctx *ctx) 119 { 120 struct nouveau_drm *drm = nouveau_drm(plane->dev); 121 struct nvif_object *dev = &drm->client.device.object; 122 struct nouveau_plane *nv_plane = 123 container_of(plane, struct nouveau_plane, base); 124 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb); 125 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 126 struct nouveau_bo *cur = nv_plane->cur; 127 bool flip = nv_plane->flip; 128 int soff = NV_PCRTC0_SIZE * nv_crtc->index; 129 int soff2 = NV_PCRTC0_SIZE * !nv_crtc->index; 130 unsigned shift = drm->client.device.info.chipset >= 0x30 ? 1 : 3; 131 unsigned format = 0; 132 int ret; 133 134 /* Source parameters given in 16.16 fixed point, ignore fractional. */ 135 src_x >>= 16; 136 src_y >>= 16; 137 src_w >>= 16; 138 src_h >>= 16; 139 140 ret = verify_scaling(fb, shift, 0, 0, src_w, src_h, crtc_w, crtc_h); 141 if (ret) 142 return ret; 143 144 ret = nouveau_bo_pin(nv_fb->nvbo, TTM_PL_FLAG_VRAM, false); 145 if (ret) 146 return ret; 147 148 nv_plane->cur = nv_fb->nvbo; 149 150 nvif_mask(dev, NV_PCRTC_ENGINE_CTRL + soff, NV_CRTC_FSEL_OVERLAY, NV_CRTC_FSEL_OVERLAY); 151 nvif_mask(dev, NV_PCRTC_ENGINE_CTRL + soff2, NV_CRTC_FSEL_OVERLAY, 0); 152 153 nvif_wr32(dev, NV_PVIDEO_BASE(flip), 0); 154 nvif_wr32(dev, NV_PVIDEO_OFFSET_BUFF(flip), nv_fb->nvbo->bo.offset); 155 nvif_wr32(dev, NV_PVIDEO_SIZE_IN(flip), src_h << 16 | src_w); 156 nvif_wr32(dev, NV_PVIDEO_POINT_IN(flip), src_y << 16 | src_x); 157 nvif_wr32(dev, NV_PVIDEO_DS_DX(flip), (src_w << 20) / crtc_w); 158 nvif_wr32(dev, NV_PVIDEO_DT_DY(flip), (src_h << 20) / crtc_h); 159 nvif_wr32(dev, NV_PVIDEO_POINT_OUT(flip), crtc_y << 16 | crtc_x); 160 nvif_wr32(dev, NV_PVIDEO_SIZE_OUT(flip), crtc_h << 16 | crtc_w); 161 162 if (fb->format->format == DRM_FORMAT_YUYV || 163 fb->format->format == DRM_FORMAT_NV12) 164 format |= NV_PVIDEO_FORMAT_COLOR_LE_CR8YB8CB8YA8; 165 if (fb->format->format == DRM_FORMAT_NV12 || 166 fb->format->format == DRM_FORMAT_NV21) 167 format |= NV_PVIDEO_FORMAT_PLANAR;
168 if (nv_plane->color_encoding == DRM_COLOR_YCBCR_BT709)
169 format |= NV_PVIDEO_FORMAT_MATRIX_ITURBT709; 170 if (nv_plane->colorkey & (1 << 24)) 171 format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY; 172 173 if (format & NV_PVIDEO_FORMAT_PLANAR) { 174 nvif_wr32(dev, NV_PVIDEO_UVPLANE_BASE(flip), 0); 175 nvif_wr32(dev, NV_PVIDEO_UVPLANE_OFFSET_BUFF(flip), 176 nv_fb->nvbo->bo.offset + fb->offsets[1]); 177 } 178 nvif_wr32(dev, NV_PVIDEO_FORMAT(flip), format | fb->pitches[0]); 179 nvif_wr32(dev, NV_PVIDEO_STOP, 0); 180 /* TODO: wait for vblank? */ 181 nvif_wr32(dev, NV_PVIDEO_BUFFER, flip ? 0x10 : 0x1); 182 nv_plane->flip = !flip; 183 184 if (cur) 185 nouveau_bo_unpin(cur); 186 187 return 0; 188 } 189 190 static int 191 nv10_disable_plane(struct drm_plane *plane, 192 struct drm_modeset_acquire_ctx *ctx) 193 { 194 struct nvif_object *dev = &nouveau_drm(plane->dev)->client.device.object; 195 struct nouveau_plane *nv_plane = 196 container_of(plane, struct nouveau_plane, base); 197 198 nvif_wr32(dev, NV_PVIDEO_STOP, 1); 199 if (nv_plane->cur) { 200 nouveau_bo_unpin(nv_plane->cur); 201 nv_plane->cur = NULL; 202 } 203 204 return 0; 205 } 206 207 static void 208 nv_destroy_plane(struct drm_plane *plane) 209 { 210 drm_plane_force_disable(plane); 211 drm_plane_cleanup(plane); 212 kfree(plane); 213 } 214 215 static void 216 nv10_set_params(struct nouveau_plane *plane) 217 { 218 struct nvif_object *dev = &nouveau_drm(plane->base.dev)->client.device.object; 219 u32 luma = (plane->brightness - 512) << 16 | plane->contrast; 220 u32 chroma = ((sin_mul(plane->hue, plane->saturation) & 0xffff) << 16) | 221 (cos_mul(plane->hue, plane->saturation) & 0xffff); 222 u32 format = 0; 223 224 nvif_wr32(dev, NV_PVIDEO_LUMINANCE(0), luma); 225 nvif_wr32(dev, NV_PVIDEO_LUMINANCE(1), luma); 226 nvif_wr32(dev, NV_PVIDEO_CHROMINANCE(0), chroma); 227 nvif_wr32(dev, NV_PVIDEO_CHROMINANCE(1), chroma); 228 nvif_wr32(dev, NV_PVIDEO_COLOR_KEY, plane->colorkey & 0xffffff); 229 230 if (plane->cur) {
231 if (plane->color_encoding == DRM_COLOR_YCBCR_BT709)
232 format |= NV_PVIDEO_FORMAT_MATRIX_ITURBT709; 233 if (plane->colorkey & (1 << 24)) 234 format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY; 235 nvif_mask(dev, NV_PVIDEO_FORMAT(plane->flip), 236 NV_PVIDEO_FORMAT_MATRIX_ITURBT709 | 237 NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY, 238 format); 239 } 240 } 241
--- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
dri-devel@lists.freedesktop.org