Skip to content

Commit 8cbd0c7

Browse files
Merge tag 'topic/hdr-formats-2019-03-13' of git://anongit.freedesktop.org/drm/drm-misc into drm-intel-next-queued
Add support for floating point half-width formats. Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/00b96cd5-91c7-5677-9620-b138c7a92303@linux.intel.com
2 parents baa09e7 + a94bed6 commit 8cbd0c7

6 files changed

Lines changed: 120 additions & 12 deletions

File tree

‎drivers/gpu/drm/drm_fourcc.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ const struct drm_format_info *__drm_format_info(u32 format)
198198
{ .format = DRM_FORMAT_ABGR8888, .depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
199199
{ .format = DRM_FORMAT_RGBA8888, .depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
200200
{ .format = DRM_FORMAT_BGRA8888, .depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
201+
{ .format = DRM_FORMAT_XRGB16161616F, .depth = 0, .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1 },
202+
{ .format = DRM_FORMAT_XBGR16161616F, .depth = 0, .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1 },
203+
{ .format = DRM_FORMAT_ARGB16161616F, .depth = 0, .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
204+
{ .format = DRM_FORMAT_ABGR16161616F, .depth = 0, .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
201205
{ .format = DRM_FORMAT_RGB888_A8, .depth = 32, .num_planes = 2, .cpp = { 3, 1, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
202206
{ .format = DRM_FORMAT_BGR888_A8, .depth = 32, .num_planes = 2, .cpp = { 3, 1, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
203207
{ .format = DRM_FORMAT_XRGB8888_A8, .depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },

‎drivers/gpu/drm/i915/intel_atomic.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,11 @@ static void intel_atomic_setup_scaler(struct intel_crtc_scaler_state *scaler_sta
234234
if (plane_state && plane_state->base.fb &&
235235
plane_state->base.fb->format->is_yuv &&
236236
plane_state->base.fb->format->num_planes > 1) {
237+
struct intel_plane *plane = to_intel_plane(plane_state->base.plane);
237238
if (IS_GEN(dev_priv, 9) &&
238239
!IS_GEMINILAKE(dev_priv)) {
239240
mode = SKL_PS_SCALER_MODE_NV12;
240-
} else if (icl_is_hdr_plane(to_intel_plane(plane_state->base.plane))) {
241+
} else if (icl_is_hdr_plane(dev_priv, plane->id)) {
241242
/*
242243
* On gen11+'s HDR planes we only use the scaler for
243244
* scaling. They have a dedicated chroma upsampler, so

‎drivers/gpu/drm/i915/intel_display.c‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2680,6 +2680,18 @@ int skl_format_to_fourcc(int format, bool rgb_order, bool alpha)
26802680
return DRM_FORMAT_XBGR2101010;
26812681
else
26822682
return DRM_FORMAT_XRGB2101010;
2683+
case PLANE_CTL_FORMAT_XRGB_16161616F:
2684+
if (rgb_order) {
2685+
if (alpha)
2686+
return DRM_FORMAT_ABGR16161616F;
2687+
else
2688+
return DRM_FORMAT_XBGR16161616F;
2689+
} else {
2690+
if (alpha)
2691+
return DRM_FORMAT_ARGB16161616F;
2692+
else
2693+
return DRM_FORMAT_XRGB16161616F;
2694+
}
26832695
}
26842696
}
26852697

@@ -3575,6 +3587,12 @@ static u32 skl_plane_ctl_format(u32 pixel_format)
35753587
return PLANE_CTL_FORMAT_XRGB_2101010;
35763588
case DRM_FORMAT_XBGR2101010:
35773589
return PLANE_CTL_ORDER_RGBX | PLANE_CTL_FORMAT_XRGB_2101010;
3590+
case DRM_FORMAT_XBGR16161616F:
3591+
case DRM_FORMAT_ABGR16161616F:
3592+
return PLANE_CTL_FORMAT_XRGB_16161616F | PLANE_CTL_ORDER_RGBX;
3593+
case DRM_FORMAT_XRGB16161616F:
3594+
case DRM_FORMAT_ARGB16161616F:
3595+
return PLANE_CTL_FORMAT_XRGB_16161616F;
35783596
case DRM_FORMAT_YUYV:
35793597
return PLANE_CTL_FORMAT_YUV422 | PLANE_CTL_YUV422_YUYV;
35803598
case DRM_FORMAT_YVYU:
@@ -3781,14 +3799,16 @@ u32 glk_plane_color_ctl_crtc(const struct intel_crtc_state *crtc_state)
37813799
u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,
37823800
const struct intel_plane_state *plane_state)
37833801
{
3802+
struct drm_i915_private *dev_priv =
3803+
to_i915(plane_state->base.plane->dev);
37843804
const struct drm_framebuffer *fb = plane_state->base.fb;
37853805
struct intel_plane *plane = to_intel_plane(plane_state->base.plane);
37863806
u32 plane_color_ctl = 0;
37873807

37883808
plane_color_ctl |= PLANE_COLOR_PLANE_GAMMA_DISABLE;
37893809
plane_color_ctl |= glk_plane_color_ctl_alpha(plane_state);
37903810

3791-
if (fb->format->is_yuv && !icl_is_hdr_plane(plane)) {
3811+
if (fb->format->is_yuv && !icl_is_hdr_plane(dev_priv, plane->id)) {
37923812
if (plane_state->base.color_encoding == DRM_COLOR_YCBCR_BT709)
37933813
plane_color_ctl |= PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709;
37943814
else
@@ -5101,13 +5121,14 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
51015121
{
51025122
struct intel_plane *intel_plane =
51035123
to_intel_plane(plane_state->base.plane);
5124+
struct drm_i915_private *dev_priv = to_i915(intel_plane->base.dev);
51045125
struct drm_framebuffer *fb = plane_state->base.fb;
51055126
int ret;
51065127
bool force_detach = !fb || !plane_state->base.visible;
51075128
bool need_scaler = false;
51085129

51095130
/* Pre-gen11 and SDR planes always need a scaler for planar formats. */
5110-
if (!icl_is_hdr_plane(intel_plane) &&
5131+
if (!icl_is_hdr_plane(dev_priv, intel_plane->id) &&
51115132
fb && is_planar_yuv_format(fb->format->format))
51125133
need_scaler = true;
51135134

@@ -5140,6 +5161,10 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
51405161
case DRM_FORMAT_ARGB8888:
51415162
case DRM_FORMAT_XRGB2101010:
51425163
case DRM_FORMAT_XBGR2101010:
5164+
case DRM_FORMAT_XBGR16161616F:
5165+
case DRM_FORMAT_ABGR16161616F:
5166+
case DRM_FORMAT_XRGB16161616F:
5167+
case DRM_FORMAT_ARGB16161616F:
51435168
case DRM_FORMAT_YUYV:
51445169
case DRM_FORMAT_YVYU:
51455170
case DRM_FORMAT_UYVY:

‎drivers/gpu/drm/i915/intel_drv.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,12 +2440,13 @@ static inline bool icl_is_nv12_y_plane(enum plane_id id)
24402440
return false;
24412441
}
24422442

2443-
static inline bool icl_is_hdr_plane(struct intel_plane *plane)
2443+
static inline bool icl_is_hdr_plane(struct drm_i915_private *dev_priv,
2444+
enum plane_id plane_id)
24442445
{
2445-
if (INTEL_GEN(to_i915(plane->base.dev)) < 11)
2446+
if (INTEL_GEN(dev_priv) < 11)
24462447
return false;
24472448

2448-
return plane->id < PLANE_SPRITE2;
2449+
return plane_id < PLANE_SPRITE2;
24492450
}
24502451

24512452
/* intel_tv.c */

‎drivers/gpu/drm/i915/intel_sprite.c‎

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ skl_program_scaler(struct intel_plane *plane,
349349

350350
/* TODO: handle sub-pixel coordinates */
351351
if (is_planar_yuv_format(plane_state->base.fb->format->format) &&
352-
!icl_is_hdr_plane(plane)) {
352+
!icl_is_hdr_plane(dev_priv, plane->id)) {
353353
y_hphase = skl_scaler_calc_phase(1, hscale, false);
354354
y_vphase = skl_scaler_calc_phase(1, vscale, false);
355355

@@ -531,7 +531,7 @@ skl_program_plane(struct intel_plane *plane,
531531
I915_WRITE_FW(PLANE_AUX_DIST(pipe, plane_id),
532532
(plane_state->color_plane[1].offset - surf_addr) | aux_stride);
533533

534-
if (icl_is_hdr_plane(plane)) {
534+
if (icl_is_hdr_plane(dev_priv, plane_id)) {
535535
u32 cus_ctl = 0;
536536

537537
if (linked) {
@@ -555,7 +555,7 @@ skl_program_plane(struct intel_plane *plane,
555555
if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv))
556556
I915_WRITE_FW(PLANE_COLOR_CTL(pipe, plane_id), plane_color_ctl);
557557

558-
if (fb->format->is_yuv && icl_is_hdr_plane(plane))
558+
if (fb->format->is_yuv && icl_is_hdr_plane(dev_priv, plane_id))
559559
icl_program_input_csc(plane, crtc_state, plane_state);
560560

561561
skl_write_plane_wm(plane, crtc_state);
@@ -1508,15 +1508,17 @@ static int skl_plane_check_fb(const struct intel_crtc_state *crtc_state,
15081508
/*
15091509
* 90/270 is not allowed with RGB64 16:16:16:16 and
15101510
* Indexed 8-bit. RGB 16-bit 5:6:5 is allowed gen11 onwards.
1511-
* TBD: Add RGB64 case once its added in supported format
1512-
* list.
15131511
*/
15141512
switch (fb->format->format) {
15151513
case DRM_FORMAT_RGB565:
15161514
if (INTEL_GEN(dev_priv) >= 11)
15171515
break;
15181516
/* fall through */
15191517
case DRM_FORMAT_C8:
1518+
case DRM_FORMAT_XRGB16161616F:
1519+
case DRM_FORMAT_XBGR16161616F:
1520+
case DRM_FORMAT_ARGB16161616F:
1521+
case DRM_FORMAT_ABGR16161616F:
15201522
DRM_DEBUG_KMS("Unsupported pixel format %s for 90/270!\n",
15211523
drm_get_format_name(fb->format->format,
15221524
&format_name));
@@ -1837,6 +1839,31 @@ static const uint32_t icl_plane_formats[] = {
18371839
DRM_FORMAT_Y416,
18381840
};
18391841

1842+
static const uint32_t icl_hdr_plane_formats[] = {
1843+
DRM_FORMAT_C8,
1844+
DRM_FORMAT_RGB565,
1845+
DRM_FORMAT_XRGB8888,
1846+
DRM_FORMAT_XBGR8888,
1847+
DRM_FORMAT_ARGB8888,
1848+
DRM_FORMAT_ABGR8888,
1849+
DRM_FORMAT_XRGB2101010,
1850+
DRM_FORMAT_XBGR2101010,
1851+
DRM_FORMAT_XRGB16161616F,
1852+
DRM_FORMAT_XBGR16161616F,
1853+
DRM_FORMAT_ARGB16161616F,
1854+
DRM_FORMAT_ABGR16161616F,
1855+
DRM_FORMAT_YUYV,
1856+
DRM_FORMAT_YVYU,
1857+
DRM_FORMAT_UYVY,
1858+
DRM_FORMAT_VYUY,
1859+
DRM_FORMAT_Y210,
1860+
DRM_FORMAT_Y212,
1861+
DRM_FORMAT_Y216,
1862+
DRM_FORMAT_Y410,
1863+
DRM_FORMAT_Y412,
1864+
DRM_FORMAT_Y416,
1865+
};
1866+
18401867
static const u32 skl_planar_formats[] = {
18411868
DRM_FORMAT_C8,
18421869
DRM_FORMAT_RGB565,
@@ -1897,6 +1924,35 @@ static const uint32_t icl_planar_formats[] = {
18971924
DRM_FORMAT_Y416,
18981925
};
18991926

1927+
static const uint32_t icl_hdr_planar_formats[] = {
1928+
DRM_FORMAT_C8,
1929+
DRM_FORMAT_RGB565,
1930+
DRM_FORMAT_XRGB8888,
1931+
DRM_FORMAT_XBGR8888,
1932+
DRM_FORMAT_ARGB8888,
1933+
DRM_FORMAT_ABGR8888,
1934+
DRM_FORMAT_XRGB2101010,
1935+
DRM_FORMAT_XBGR2101010,
1936+
DRM_FORMAT_XRGB16161616F,
1937+
DRM_FORMAT_XBGR16161616F,
1938+
DRM_FORMAT_ARGB16161616F,
1939+
DRM_FORMAT_ABGR16161616F,
1940+
DRM_FORMAT_YUYV,
1941+
DRM_FORMAT_YVYU,
1942+
DRM_FORMAT_UYVY,
1943+
DRM_FORMAT_VYUY,
1944+
DRM_FORMAT_NV12,
1945+
DRM_FORMAT_P010,
1946+
DRM_FORMAT_P012,
1947+
DRM_FORMAT_P016,
1948+
DRM_FORMAT_Y210,
1949+
DRM_FORMAT_Y212,
1950+
DRM_FORMAT_Y216,
1951+
DRM_FORMAT_Y410,
1952+
DRM_FORMAT_Y412,
1953+
DRM_FORMAT_Y416,
1954+
};
1955+
19001956
static const u64 skl_plane_format_modifiers_noccs[] = {
19011957
I915_FORMAT_MOD_Yf_TILED,
19021958
I915_FORMAT_MOD_Y_TILED,
@@ -2049,6 +2105,10 @@ static bool skl_plane_format_mod_supported(struct drm_plane *_plane,
20492105
return true;
20502106
/* fall through */
20512107
case DRM_FORMAT_C8:
2108+
case DRM_FORMAT_XBGR16161616F:
2109+
case DRM_FORMAT_ABGR16161616F:
2110+
case DRM_FORMAT_XRGB16161616F:
2111+
case DRM_FORMAT_ARGB16161616F:
20522112
if (modifier == DRM_FORMAT_MOD_LINEAR ||
20532113
modifier == I915_FORMAT_MOD_X_TILED ||
20542114
modifier == I915_FORMAT_MOD_Y_TILED)
@@ -2185,7 +2245,10 @@ skl_universal_plane_create(struct drm_i915_private *dev_priv,
21852245
plane->update_slave = icl_update_slave;
21862246

21872247
if (skl_plane_has_planar(dev_priv, pipe, plane_id)) {
2188-
if (INTEL_GEN(dev_priv) >= 11) {
2248+
if (icl_is_hdr_plane(dev_priv, plane_id)) {
2249+
formats = icl_hdr_planar_formats;
2250+
num_formats = ARRAY_SIZE(icl_hdr_planar_formats);
2251+
} else if (INTEL_GEN(dev_priv) >= 11) {
21892252
formats = icl_planar_formats;
21902253
num_formats = ARRAY_SIZE(icl_planar_formats);
21912254
} else if (INTEL_GEN(dev_priv) == 10 || IS_GEMINILAKE(dev_priv)) {
@@ -2195,6 +2258,9 @@ skl_universal_plane_create(struct drm_i915_private *dev_priv,
21952258
formats = skl_planar_formats;
21962259
num_formats = ARRAY_SIZE(skl_planar_formats);
21972260
}
2261+
} else if (icl_is_hdr_plane(dev_priv, plane_id)) {
2262+
formats = icl_hdr_plane_formats;
2263+
num_formats = ARRAY_SIZE(icl_hdr_plane_formats);
21982264
} else if (INTEL_GEN(dev_priv) >= 11) {
21992265
formats = icl_plane_formats;
22002266
num_formats = ARRAY_SIZE(icl_plane_formats);

‎include/uapi/drm/drm_fourcc.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@ extern "C" {
144144
#define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */
145145
#define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */
146146

147+
/*
148+
* Floating point 64bpp RGB
149+
* IEEE 754-2008 binary16 half-precision float
150+
* [15:0] sign:exponent:mantissa 1:5:10
151+
*/
152+
#define DRM_FORMAT_XRGB16161616F fourcc_code('X', 'R', '4', 'H') /* [63:0] x:R:G:B 16:16:16:16 little endian */
153+
#define DRM_FORMAT_XBGR16161616F fourcc_code('X', 'B', '4', 'H') /* [63:0] x:B:G:R 16:16:16:16 little endian */
154+
155+
#define DRM_FORMAT_ARGB16161616F fourcc_code('A', 'R', '4', 'H') /* [63:0] A:R:G:B 16:16:16:16 little endian */
156+
#define DRM_FORMAT_ABGR16161616F fourcc_code('A', 'B', '4', 'H') /* [63:0] A:B:G:R 16:16:16:16 little endian */
157+
147158
/* packed YCbCr */
148159
#define DRM_FORMAT_YUYV fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */
149160
#define DRM_FORMAT_YVYU fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */

0 commit comments

Comments
 (0)