2018-02-01 10:44:22

by Philippe Cornu

[permalink] [raw]
Subject: [PATCH v1 0/2] drm/stm: ltdc: add non-alpha color formats

This patchset adds non-alpha color format support taking into
account older hw versions.

Philippe Cornu (2):
drm/stm: ltdc: add non-alpha color formats
drm/stm: ltdc: remove non-alpha color formats on layer 2 for older hw

drivers/gpu/drm/stm/ltdc.c | 53 ++++++++++++++++++++++++++++++++++++++++++++--
drivers/gpu/drm/stm/ltdc.h | 1 +
2 files changed, 52 insertions(+), 2 deletions(-)

--
2.15.1



2018-02-01 10:44:05

by Philippe Cornu

[permalink] [raw]
Subject: [PATCH v1 1/2] drm/stm: ltdc: add non-alpha color formats

ltdc supports natively some color formats with alpha (like
ARGB8888, ARGB1555, ARGB4444...). Related non-alpha formats are
supported too (ARGB8888->XRGB8888, ARGB4444->XRGB4444...) by
adjusting ltdc blending factors.

Note: Wayland/Weston requests by default the non-alpha XRGB8888
color format.

Signed-off-by: Philippe Cornu <[email protected]>
---
drivers/gpu/drm/stm/ltdc.c | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index 90b3de516c91..f6f26fc0ae9e 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -328,6 +328,26 @@ static inline u32 to_drm_pixelformat(enum ltdc_pix_fmt pf)
}
}

+static inline u32 get_pixelformat_without_alpha(u32 drm)
+{
+ switch (drm) {
+ case DRM_FORMAT_ARGB4444:
+ return DRM_FORMAT_XRGB4444;
+ case DRM_FORMAT_RGBA4444:
+ return DRM_FORMAT_RGBX4444;
+ case DRM_FORMAT_ARGB1555:
+ return DRM_FORMAT_XRGB1555;
+ case DRM_FORMAT_RGBA5551:
+ return DRM_FORMAT_RGBX5551;
+ case DRM_FORMAT_ARGB8888:
+ return DRM_FORMAT_XRGB8888;
+ case DRM_FORMAT_RGBA8888:
+ return DRM_FORMAT_RGBX8888;
+ default:
+ return 0;
+ }
+}
+
static irqreturn_t ltdc_irq_thread(int irq, void *arg)
{
struct drm_device *ddev = arg;
@@ -680,6 +700,9 @@ static void ltdc_plane_atomic_update(struct drm_plane *plane,

/* Specifies the blending factors */
val = BF1_PAXCA | BF2_1PAXCA;
+ if (!fb->format->has_alpha)
+ val = BF1_CA | BF2_1CA;
+
reg_update_bits(ldev->regs, LTDC_L1BFCR + lofs,
LXBFCR_BF2 | LXBFCR_BF1, val);

@@ -747,8 +770,8 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev,
struct device *dev = ddev->dev;
struct drm_plane *plane;
unsigned int i, nb_fmt = 0;
- u32 formats[NB_PF];
- u32 drm_fmt;
+ u32 formats[NB_PF * 2];
+ u32 drm_fmt, drm_fmt_no_alpha;
int ret;

/* Get supported pixel formats */
@@ -757,6 +780,12 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev,
if (!drm_fmt)
continue;
formats[nb_fmt++] = drm_fmt;
+
+ /* Add the no-alpha related format if any & supported */
+ drm_fmt_no_alpha = get_pixelformat_without_alpha(drm_fmt);
+ if (!drm_fmt_no_alpha)
+ continue;
+ formats[nb_fmt++] = drm_fmt_no_alpha;
}

plane = devm_kzalloc(dev, sizeof(*plane), GFP_KERNEL);
--
2.15.1


2018-02-01 10:45:09

by Philippe Cornu

[permalink] [raw]
Subject: [PATCH v1 2/2] drm/stm: ltdc: remove non-alpha color formats on layer 2 for older hw

Hw older versions support non-alpha color formats derived
from native alpha color formats only on the primary layer.
For instance, RG16 native format without alpha works fine
on 2nd layer but XR24 (derived color format from AR24)
does not work on 2nd layer.

Signed-off-by: Philippe Cornu <[email protected]>
---
drivers/gpu/drm/stm/ltdc.c | 20 ++++++++++++++++++++
drivers/gpu/drm/stm/ltdc.h | 1 +
2 files changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index f6f26fc0ae9e..1a3277e483d5 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -703,6 +703,11 @@ static void ltdc_plane_atomic_update(struct drm_plane *plane,
if (!fb->format->has_alpha)
val = BF1_CA | BF2_1CA;

+ /* Manage hw-specific capabilities */
+ if (ldev->caps.non_alpha_only_l1 &&
+ plane->type != DRM_PLANE_TYPE_PRIMARY)
+ val = BF1_PAXCA | BF2_1PAXCA;
+
reg_update_bits(ldev->regs, LTDC_L1BFCR + lofs,
LXBFCR_BF2 | LXBFCR_BF1, val);

@@ -785,6 +790,12 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev,
drm_fmt_no_alpha = get_pixelformat_without_alpha(drm_fmt);
if (!drm_fmt_no_alpha)
continue;
+
+ /* Manage hw-specific capabilities */
+ if (ldev->caps.non_alpha_only_l1 &&
+ type != DRM_PLANE_TYPE_PRIMARY)
+ continue;
+
formats[nb_fmt++] = drm_fmt_no_alpha;
}

@@ -913,10 +924,19 @@ static int ltdc_get_caps(struct drm_device *ddev)
case HWVER_10300:
ldev->caps.reg_ofs = REG_OFS_NONE;
ldev->caps.pix_fmt_hw = ltdc_pix_fmt_a0;
+ /*
+ * Hw older versions support non-alpha color formats derived
+ * from native alpha color formats only on the primary layer.
+ * For instance, RG16 native format without alpha works fine
+ * on 2nd layer but XR24 (derived color format from AR24)
+ * does not work on 2nd layer.
+ */
+ ldev->caps.non_alpha_only_l1 = true;
break;
case HWVER_20101:
ldev->caps.reg_ofs = REG_OFS_4;
ldev->caps.pix_fmt_hw = ltdc_pix_fmt_a1;
+ ldev->caps.non_alpha_only_l1 = false;
break;
default:
return -ENODEV;
diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h
index edd1c0a446d1..edb268129c54 100644
--- a/drivers/gpu/drm/stm/ltdc.h
+++ b/drivers/gpu/drm/stm/ltdc.h
@@ -17,6 +17,7 @@ struct ltdc_caps {
u32 reg_ofs; /* register offset for applicable regs */
u32 bus_width; /* bus width (32 or 64 bits) */
const u32 *pix_fmt_hw; /* supported pixel formats */
+ bool non_alpha_only_l1; /* non-native no-alpha formats on layer 1 */
};

struct ltdc_device {
--
2.15.1


2018-02-05 19:25:12

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] drm/stm: ltdc: add non-alpha color formats

Hi Philippe,

I love your patch! Yet something to improve:

[auto build test ERROR on drm/drm-next]
[also build test ERROR on v4.15 next-20180205]
[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/Philippe-Cornu/drm-stm-ltdc-add-non-alpha-color-formats/20180201-211736
base: git://people.freedesktop.org/~airlied/linux.git drm-next
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm

All errors (new ones prefixed by >>):

drivers/gpu//drm/stm/ltdc.c: In function 'ltdc_plane_atomic_update':
>> drivers/gpu//drm/stm/ltdc.c:661:17: error: 'const struct drm_format_info' has no member named 'has_alpha'
if (!fb->format->has_alpha)
^~

vim +661 drivers/gpu//drm/stm/ltdc.c

587
588 static void ltdc_plane_atomic_update(struct drm_plane *plane,
589 struct drm_plane_state *oldstate)
590 {
591 struct ltdc_device *ldev = plane_to_ltdc(plane);
592 struct drm_plane_state *state = plane->state;
593 struct drm_framebuffer *fb = state->fb;
594 u32 lofs = plane->index * LAY_OFS;
595 u32 x0 = state->crtc_x;
596 u32 x1 = state->crtc_x + state->crtc_w - 1;
597 u32 y0 = state->crtc_y;
598 u32 y1 = state->crtc_y + state->crtc_h - 1;
599 u32 src_x, src_y, src_w, src_h;
600 u32 val, pitch_in_bytes, line_length, paddr, ahbp, avbp, bpcr;
601 enum ltdc_pix_fmt pf;
602
603 if (!state->crtc || !fb) {
604 DRM_DEBUG_DRIVER("fb or crtc NULL");
605 return;
606 }
607
608 /* convert src_ from 16:16 format */
609 src_x = state->src_x >> 16;
610 src_y = state->src_y >> 16;
611 src_w = state->src_w >> 16;
612 src_h = state->src_h >> 16;
613
614 DRM_DEBUG_DRIVER("plane:%d fb:%d (%dx%d)@(%d,%d) -> (%dx%d)@(%d,%d)\n",
615 plane->base.id, fb->base.id,
616 src_w, src_h, src_x, src_y,
617 state->crtc_w, state->crtc_h,
618 state->crtc_x, state->crtc_y);
619
620 bpcr = reg_read(ldev->regs, LTDC_BPCR);
621 ahbp = (bpcr & BPCR_AHBP) >> 16;
622 avbp = bpcr & BPCR_AVBP;
623
624 /* Configures the horizontal start and stop position */
625 val = ((x1 + 1 + ahbp) << 16) + (x0 + 1 + ahbp);
626 reg_update_bits(ldev->regs, LTDC_L1WHPCR + lofs,
627 LXWHPCR_WHSTPOS | LXWHPCR_WHSPPOS, val);
628
629 /* Configures the vertical start and stop position */
630 val = ((y1 + 1 + avbp) << 16) + (y0 + 1 + avbp);
631 reg_update_bits(ldev->regs, LTDC_L1WVPCR + lofs,
632 LXWVPCR_WVSTPOS | LXWVPCR_WVSPPOS, val);
633
634 /* Specifies the pixel format */
635 pf = to_ltdc_pixelformat(fb->format->format);
636 for (val = 0; val < NB_PF; val++)
637 if (ldev->caps.pix_fmt_hw[val] == pf)
638 break;
639
640 if (val == NB_PF) {
641 DRM_ERROR("Pixel format %.4s not supported\n",
642 (char *)&fb->format->format);
643 val = 0; /* set by default ARGB 32 bits */
644 }
645 reg_update_bits(ldev->regs, LTDC_L1PFCR + lofs, LXPFCR_PF, val);
646
647 /* Configures the color frame buffer pitch in bytes & line length */
648 pitch_in_bytes = fb->pitches[0];
649 line_length = drm_format_plane_cpp(fb->format->format, 0) *
650 (x1 - x0 + 1) + (ldev->caps.bus_width >> 3) - 1;
651 val = ((pitch_in_bytes << 16) | line_length);
652 reg_update_bits(ldev->regs, LTDC_L1CFBLR + lofs,
653 LXCFBLR_CFBLL | LXCFBLR_CFBP, val);
654
655 /* Specifies the constant alpha value */
656 val = CONSTA_MAX;
657 reg_update_bits(ldev->regs, LTDC_L1CACR + lofs, LXCACR_CONSTA, val);
658
659 /* Specifies the blending factors */
660 val = BF1_PAXCA | BF2_1PAXCA;
> 661 if (!fb->format->has_alpha)
662 val = BF1_CA | BF2_1CA;
663
664 reg_update_bits(ldev->regs, LTDC_L1BFCR + lofs,
665 LXBFCR_BF2 | LXBFCR_BF1, val);
666
667 /* Configures the frame buffer line number */
668 val = y1 - y0 + 1;
669 reg_update_bits(ldev->regs, LTDC_L1CFBLNR + lofs, LXCFBLNR_CFBLN, val);
670
671 /* Sets the FB address */
672 paddr = (u32)drm_fb_cma_get_gem_addr(fb, state, 0);
673
674 DRM_DEBUG_DRIVER("fb: phys 0x%08x", paddr);
675 reg_write(ldev->regs, LTDC_L1CFBAR + lofs, paddr);
676
677 /* Enable layer and CLUT if needed */
678 val = fb->format->format == DRM_FORMAT_C8 ? LXCR_CLUTEN : 0;
679 val |= LXCR_LEN;
680 reg_update_bits(ldev->regs, LTDC_L1CR + lofs,
681 LXCR_LEN | LXCR_CLUTEN, val);
682
683 mutex_lock(&ldev->err_lock);
684 if (ldev->error_status & ISR_FUIF) {
685 DRM_DEBUG_DRIVER("Fifo underrun\n");
686 ldev->error_status &= ~ISR_FUIF;
687 }
688 if (ldev->error_status & ISR_TERRIF) {
689 DRM_DEBUG_DRIVER("Transfer error\n");
690 ldev->error_status &= ~ISR_TERRIF;
691 }
692 mutex_unlock(&ldev->err_lock);
693 }
694

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (5.41 kB)
.config.gz (63.23 kB)
Download all attachments

2018-02-06 09:14:42

by Yannick FERTRE

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] drm/stm: ltdc: add non-alpha color formats

Reviewed-by: Yannick Fertré <[email protected]>


On 02/01/2018 11:42 AM, Philippe Cornu wrote:
> ltdc supports natively some color formats with alpha (like
> ARGB8888, ARGB1555, ARGB4444...). Related non-alpha formats are
> supported too (ARGB8888->XRGB8888, ARGB4444->XRGB4444...) by
> adjusting ltdc blending factors.
>
> Note: Wayland/Weston requests by default the non-alpha XRGB8888
> color format.
>
> Signed-off-by: Philippe Cornu <[email protected]>
> ---
> drivers/gpu/drm/stm/ltdc.c | 33 +++++++++++++++++++++++++++++++--
> 1 file changed, 31 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> index 90b3de516c91..f6f26fc0ae9e 100644
> --- a/drivers/gpu/drm/stm/ltdc.c
> +++ b/drivers/gpu/drm/stm/ltdc.c
> @@ -328,6 +328,26 @@ static inline u32 to_drm_pixelformat(enum ltdc_pix_fmt pf)
> }
> }
>
> +static inline u32 get_pixelformat_without_alpha(u32 drm)
> +{
> + switch (drm) {
> + case DRM_FORMAT_ARGB4444:
> + return DRM_FORMAT_XRGB4444;
> + case DRM_FORMAT_RGBA4444:
> + return DRM_FORMAT_RGBX4444;
> + case DRM_FORMAT_ARGB1555:
> + return DRM_FORMAT_XRGB1555;
> + case DRM_FORMAT_RGBA5551:
> + return DRM_FORMAT_RGBX5551;
> + case DRM_FORMAT_ARGB8888:
> + return DRM_FORMAT_XRGB8888;
> + case DRM_FORMAT_RGBA8888:
> + return DRM_FORMAT_RGBX8888;
> + default:
> + return 0;
> + }
> +}
> +
> static irqreturn_t ltdc_irq_thread(int irq, void *arg)
> {
> struct drm_device *ddev = arg;
> @@ -680,6 +700,9 @@ static void ltdc_plane_atomic_update(struct drm_plane *plane,
>
> /* Specifies the blending factors */
> val = BF1_PAXCA | BF2_1PAXCA;
> + if (!fb->format->has_alpha)
> + val = BF1_CA | BF2_1CA;
> +
> reg_update_bits(ldev->regs, LTDC_L1BFCR + lofs,
> LXBFCR_BF2 | LXBFCR_BF1, val);
>
> @@ -747,8 +770,8 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev,
> struct device *dev = ddev->dev;
> struct drm_plane *plane;
> unsigned int i, nb_fmt = 0;
> - u32 formats[NB_PF];
> - u32 drm_fmt;
> + u32 formats[NB_PF * 2];
> + u32 drm_fmt, drm_fmt_no_alpha;
> int ret;
>
> /* Get supported pixel formats */
> @@ -757,6 +780,12 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev,
> if (!drm_fmt)
> continue;
> formats[nb_fmt++] = drm_fmt;
> +
> + /* Add the no-alpha related format if any & supported */
> + drm_fmt_no_alpha = get_pixelformat_without_alpha(drm_fmt);
> + if (!drm_fmt_no_alpha)
> + continue;
> + formats[nb_fmt++] = drm_fmt_no_alpha;
> }
>
> plane = devm_kzalloc(dev, sizeof(*plane), GFP_KERNEL);

2018-02-06 09:14:54

by Yannick FERTRE

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] drm/stm: ltdc: remove non-alpha color formats on layer 2 for older hw

Reviewed-by: Yannick Fertré <[email protected]>


On 02/01/2018 11:42 AM, Philippe Cornu wrote:
> Hw older versions support non-alpha color formats derived
> from native alpha color formats only on the primary layer.
> For instance, RG16 native format without alpha works fine
> on 2nd layer but XR24 (derived color format from AR24)
> does not work on 2nd layer.
>
> Signed-off-by: Philippe Cornu <[email protected]>
> ---
> drivers/gpu/drm/stm/ltdc.c | 20 ++++++++++++++++++++
> drivers/gpu/drm/stm/ltdc.h | 1 +
> 2 files changed, 21 insertions(+)
>
> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> index f6f26fc0ae9e..1a3277e483d5 100644
> --- a/drivers/gpu/drm/stm/ltdc.c
> +++ b/drivers/gpu/drm/stm/ltdc.c
> @@ -703,6 +703,11 @@ static void ltdc_plane_atomic_update(struct drm_plane *plane,
> if (!fb->format->has_alpha)
> val = BF1_CA | BF2_1CA;
>
> + /* Manage hw-specific capabilities */
> + if (ldev->caps.non_alpha_only_l1 &&
> + plane->type != DRM_PLANE_TYPE_PRIMARY)
> + val = BF1_PAXCA | BF2_1PAXCA;
> +
> reg_update_bits(ldev->regs, LTDC_L1BFCR + lofs,
> LXBFCR_BF2 | LXBFCR_BF1, val);
>
> @@ -785,6 +790,12 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev,
> drm_fmt_no_alpha = get_pixelformat_without_alpha(drm_fmt);
> if (!drm_fmt_no_alpha)
> continue;
> +
> + /* Manage hw-specific capabilities */
> + if (ldev->caps.non_alpha_only_l1 &&
> + type != DRM_PLANE_TYPE_PRIMARY)
> + continue;
> +
> formats[nb_fmt++] = drm_fmt_no_alpha;
> }
>
> @@ -913,10 +924,19 @@ static int ltdc_get_caps(struct drm_device *ddev)
> case HWVER_10300:
> ldev->caps.reg_ofs = REG_OFS_NONE;
> ldev->caps.pix_fmt_hw = ltdc_pix_fmt_a0;
> + /*
> + * Hw older versions support non-alpha color formats derived
> + * from native alpha color formats only on the primary layer.
> + * For instance, RG16 native format without alpha works fine
> + * on 2nd layer but XR24 (derived color format from AR24)
> + * does not work on 2nd layer.
> + */
> + ldev->caps.non_alpha_only_l1 = true;
> break;
> case HWVER_20101:
> ldev->caps.reg_ofs = REG_OFS_4;
> ldev->caps.pix_fmt_hw = ltdc_pix_fmt_a1;
> + ldev->caps.non_alpha_only_l1 = false;
> break;
> default:
> return -ENODEV;
> diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h
> index edd1c0a446d1..edb268129c54 100644
> --- a/drivers/gpu/drm/stm/ltdc.h
> +++ b/drivers/gpu/drm/stm/ltdc.h
> @@ -17,6 +17,7 @@ struct ltdc_caps {
> u32 reg_ofs; /* register offset for applicable regs */
> u32 bus_width; /* bus width (32 or 64 bits) */
> const u32 *pix_fmt_hw; /* supported pixel formats */
> + bool non_alpha_only_l1; /* non-native no-alpha formats on layer 1 */
> };
>
> struct ltdc_device {

2018-02-08 09:41:27

by Benjamin Gaignard

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] drm/stm: ltdc: add non-alpha color formats

2018-02-06 10:12 GMT+01:00 Yannick FERTRE <[email protected]>:
> Reviewed-by: Yannick Fertré <[email protected]>
>
>
> On 02/01/2018 11:42 AM, Philippe Cornu wrote:
>> ltdc supports natively some color formats with alpha (like
>> ARGB8888, ARGB1555, ARGB4444...). Related non-alpha formats are
>> supported too (ARGB8888->XRGB8888, ARGB4444->XRGB4444...) by
>> adjusting ltdc blending factors.
>>
>> Note: Wayland/Weston requests by default the non-alpha XRGB8888
>> color format.
>>
>> Signed-off-by: Philippe Cornu <[email protected]>

Applied on drm-misc-next

Benjamin
>> ---
>> drivers/gpu/drm/stm/ltdc.c | 33 +++++++++++++++++++++++++++++++--
>> 1 file changed, 31 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
>> index 90b3de516c91..f6f26fc0ae9e 100644
>> --- a/drivers/gpu/drm/stm/ltdc.c
>> +++ b/drivers/gpu/drm/stm/ltdc.c
>> @@ -328,6 +328,26 @@ static inline u32 to_drm_pixelformat(enum ltdc_pix_fmt pf)
>> }
>> }
>>
>> +static inline u32 get_pixelformat_without_alpha(u32 drm)
>> +{
>> + switch (drm) {
>> + case DRM_FORMAT_ARGB4444:
>> + return DRM_FORMAT_XRGB4444;
>> + case DRM_FORMAT_RGBA4444:
>> + return DRM_FORMAT_RGBX4444;
>> + case DRM_FORMAT_ARGB1555:
>> + return DRM_FORMAT_XRGB1555;
>> + case DRM_FORMAT_RGBA5551:
>> + return DRM_FORMAT_RGBX5551;
>> + case DRM_FORMAT_ARGB8888:
>> + return DRM_FORMAT_XRGB8888;
>> + case DRM_FORMAT_RGBA8888:
>> + return DRM_FORMAT_RGBX8888;
>> + default:
>> + return 0;
>> + }
>> +}
>> +
>> static irqreturn_t ltdc_irq_thread(int irq, void *arg)
>> {
>> struct drm_device *ddev = arg;
>> @@ -680,6 +700,9 @@ static void ltdc_plane_atomic_update(struct drm_plane *plane,
>>
>> /* Specifies the blending factors */
>> val = BF1_PAXCA | BF2_1PAXCA;
>> + if (!fb->format->has_alpha)
>> + val = BF1_CA | BF2_1CA;
>> +
>> reg_update_bits(ldev->regs, LTDC_L1BFCR + lofs,
>> LXBFCR_BF2 | LXBFCR_BF1, val);
>>
>> @@ -747,8 +770,8 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev,
>> struct device *dev = ddev->dev;
>> struct drm_plane *plane;
>> unsigned int i, nb_fmt = 0;
>> - u32 formats[NB_PF];
>> - u32 drm_fmt;
>> + u32 formats[NB_PF * 2];
>> + u32 drm_fmt, drm_fmt_no_alpha;
>> int ret;
>>
>> /* Get supported pixel formats */
>> @@ -757,6 +780,12 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev,
>> if (!drm_fmt)
>> continue;
>> formats[nb_fmt++] = drm_fmt;
>> +
>> + /* Add the no-alpha related format if any & supported */
>> + drm_fmt_no_alpha = get_pixelformat_without_alpha(drm_fmt);
>> + if (!drm_fmt_no_alpha)
>> + continue;
>> + formats[nb_fmt++] = drm_fmt_no_alpha;
>> }
>>
>> plane = devm_kzalloc(dev, sizeof(*plane), GFP_KERNEL);

2018-02-08 09:41:56

by Benjamin Gaignard

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] drm/stm: ltdc: remove non-alpha color formats on layer 2 for older hw

2018-02-06 10:13 GMT+01:00 Yannick FERTRE <[email protected]>:
> Reviewed-by: Yannick Fertré <[email protected]>
>
>
> On 02/01/2018 11:42 AM, Philippe Cornu wrote:
>> Hw older versions support non-alpha color formats derived
>> from native alpha color formats only on the primary layer.
>> For instance, RG16 native format without alpha works fine
>> on 2nd layer but XR24 (derived color format from AR24)
>> does not work on 2nd layer.
>>
>> Signed-off-by: Philippe Cornu <[email protected]>

Applied on drm-misc-next

Benjamin

>> ---
>> drivers/gpu/drm/stm/ltdc.c | 20 ++++++++++++++++++++
>> drivers/gpu/drm/stm/ltdc.h | 1 +
>> 2 files changed, 21 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
>> index f6f26fc0ae9e..1a3277e483d5 100644
>> --- a/drivers/gpu/drm/stm/ltdc.c
>> +++ b/drivers/gpu/drm/stm/ltdc.c
>> @@ -703,6 +703,11 @@ static void ltdc_plane_atomic_update(struct drm_plane *plane,
>> if (!fb->format->has_alpha)
>> val = BF1_CA | BF2_1CA;
>>
>> + /* Manage hw-specific capabilities */
>> + if (ldev->caps.non_alpha_only_l1 &&
>> + plane->type != DRM_PLANE_TYPE_PRIMARY)
>> + val = BF1_PAXCA | BF2_1PAXCA;
>> +
>> reg_update_bits(ldev->regs, LTDC_L1BFCR + lofs,
>> LXBFCR_BF2 | LXBFCR_BF1, val);
>>
>> @@ -785,6 +790,12 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev,
>> drm_fmt_no_alpha = get_pixelformat_without_alpha(drm_fmt);
>> if (!drm_fmt_no_alpha)
>> continue;
>> +
>> + /* Manage hw-specific capabilities */
>> + if (ldev->caps.non_alpha_only_l1 &&
>> + type != DRM_PLANE_TYPE_PRIMARY)
>> + continue;
>> +
>> formats[nb_fmt++] = drm_fmt_no_alpha;
>> }
>>
>> @@ -913,10 +924,19 @@ static int ltdc_get_caps(struct drm_device *ddev)
>> case HWVER_10300:
>> ldev->caps.reg_ofs = REG_OFS_NONE;
>> ldev->caps.pix_fmt_hw = ltdc_pix_fmt_a0;
>> + /*
>> + * Hw older versions support non-alpha color formats derived
>> + * from native alpha color formats only on the primary layer.
>> + * For instance, RG16 native format without alpha works fine
>> + * on 2nd layer but XR24 (derived color format from AR24)
>> + * does not work on 2nd layer.
>> + */
>> + ldev->caps.non_alpha_only_l1 = true;
>> break;
>> case HWVER_20101:
>> ldev->caps.reg_ofs = REG_OFS_4;
>> ldev->caps.pix_fmt_hw = ltdc_pix_fmt_a1;
>> + ldev->caps.non_alpha_only_l1 = false;
>> break;
>> default:
>> return -ENODEV;
>> diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h
>> index edd1c0a446d1..edb268129c54 100644
>> --- a/drivers/gpu/drm/stm/ltdc.h
>> +++ b/drivers/gpu/drm/stm/ltdc.h
>> @@ -17,6 +17,7 @@ struct ltdc_caps {
>> u32 reg_ofs; /* register offset for applicable regs */
>> u32 bus_width; /* bus width (32 or 64 bits) */
>> const u32 *pix_fmt_hw; /* supported pixel formats */
>> + bool non_alpha_only_l1; /* non-native no-alpha formats on layer 1 */
>> };
>>
>> struct ltdc_device {

2018-02-08 15:05:38

by Philippe Cornu

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] drm/stm: ltdc: add non-alpha color formats

Hi Benjamin,
and many thanks for having applied the 2 patches.
Philippe :-)

On 02/08/2018 10:40 AM, Benjamin Gaignard wrote:
> 2018-02-06 10:12 GMT+01:00 Yannick FERTRE <[email protected]>:
>> Reviewed-by: Yannick Fertré <[email protected]>
>>
>>
>> On 02/01/2018 11:42 AM, Philippe Cornu wrote:
>>> ltdc supports natively some color formats with alpha (like
>>> ARGB8888, ARGB1555, ARGB4444...). Related non-alpha formats are
>>> supported too (ARGB8888->XRGB8888, ARGB4444->XRGB4444...) by
>>> adjusting ltdc blending factors.
>>>
>>> Note: Wayland/Weston requests by default the non-alpha XRGB8888
>>> color format.
>>>
>>> Signed-off-by: Philippe Cornu <[email protected]>
>
> Applied on drm-misc-next
>
> Benjamin
>>> ---
>>> drivers/gpu/drm/stm/ltdc.c | 33 +++++++++++++++++++++++++++++++--
>>> 1 file changed, 31 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
>>> index 90b3de516c91..f6f26fc0ae9e 100644
>>> --- a/drivers/gpu/drm/stm/ltdc.c
>>> +++ b/drivers/gpu/drm/stm/ltdc.c
>>> @@ -328,6 +328,26 @@ static inline u32 to_drm_pixelformat(enum ltdc_pix_fmt pf)
>>> }
>>> }
>>>
>>> +static inline u32 get_pixelformat_without_alpha(u32 drm)
>>> +{
>>> + switch (drm) {
>>> + case DRM_FORMAT_ARGB4444:
>>> + return DRM_FORMAT_XRGB4444;
>>> + case DRM_FORMAT_RGBA4444:
>>> + return DRM_FORMAT_RGBX4444;
>>> + case DRM_FORMAT_ARGB1555:
>>> + return DRM_FORMAT_XRGB1555;
>>> + case DRM_FORMAT_RGBA5551:
>>> + return DRM_FORMAT_RGBX5551;
>>> + case DRM_FORMAT_ARGB8888:
>>> + return DRM_FORMAT_XRGB8888;
>>> + case DRM_FORMAT_RGBA8888:
>>> + return DRM_FORMAT_RGBX8888;
>>> + default:
>>> + return 0;
>>> + }
>>> +}
>>> +
>>> static irqreturn_t ltdc_irq_thread(int irq, void *arg)
>>> {
>>> struct drm_device *ddev = arg;
>>> @@ -680,6 +700,9 @@ static void ltdc_plane_atomic_update(struct drm_plane *plane,
>>>
>>> /* Specifies the blending factors */
>>> val = BF1_PAXCA | BF2_1PAXCA;
>>> + if (!fb->format->has_alpha)
>>> + val = BF1_CA | BF2_1CA;
>>> +
>>> reg_update_bits(ldev->regs, LTDC_L1BFCR + lofs,
>>> LXBFCR_BF2 | LXBFCR_BF1, val);
>>>
>>> @@ -747,8 +770,8 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev,
>>> struct device *dev = ddev->dev;
>>> struct drm_plane *plane;
>>> unsigned int i, nb_fmt = 0;
>>> - u32 formats[NB_PF];
>>> - u32 drm_fmt;
>>> + u32 formats[NB_PF * 2];
>>> + u32 drm_fmt, drm_fmt_no_alpha;
>>> int ret;
>>>
>>> /* Get supported pixel formats */
>>> @@ -757,6 +780,12 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev,
>>> if (!drm_fmt)
>>> continue;
>>> formats[nb_fmt++] = drm_fmt;
>>> +
>>> + /* Add the no-alpha related format if any & supported */
>>> + drm_fmt_no_alpha = get_pixelformat_without_alpha(drm_fmt);
>>> + if (!drm_fmt_no_alpha)
>>> + continue;
>>> + formats[nb_fmt++] = drm_fmt_no_alpha;
>>> }
>>>
>>> plane = devm_kzalloc(dev, sizeof(*plane), GFP_KERNEL);
> _______________________________________________
> dri-devel mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>