Skip to contentSkip to conversation

video: mmp: rb swap setting update for new LCD driver

PATCH New Jett.Zhou 3 participants 7 messages Jun 10, 2013 – Jun 26, 2013 1 message not in the archive Framebuffer layer

lore
Share & tools
lore

Jett.Zhou

author
#0 lore raw

PATCH v2 1/7 video: mmp: rb swap setting update for new LCD driver

From: Guoqing Li <[email protected]>

We could set rb swap in two modules: DMA controler and interface output after blending.
This patch move the panel rbswap requirement setting in later module.

---
 drivers/video/mmp/hw/mmp_ctrl.c |   15 ++++++++-------
 drivers/video/mmp/hw/mmp_ctrl.h |    4 ++++
 2 files changed, 12 insertions(+), 7 deletions(-)
drivers/video/mmp/hw/mmp_ctrl.c +8 -7
index 4bd31b2..a472c4d 100644
@@ -60,8 +60,7 @@ static irqreturn_t ctrl_handle_irq(int irq, void *dev_id)
 
 static u32 fmt_to_reg(struct mmp_overlay *overlay, int pix_fmt)
 {
-	u32 link_config = path_to_path_plat(overlay->path)->link_config;
-	u32 rbswap, uvswap = 0, yuvswap = 0,
+	u32 rbswap = 0, uvswap = 0, yuvswap = 0,
 		csc_en = 0, val = 0,
 		vid = overlay_is_vid(overlay);
 
@@ -71,27 +70,23 @@ static u32 fmt_to_reg(struct mmp_overlay *overlay, int pix_fmt)
 	case PIXFMT_RGB888PACK:
 	case PIXFMT_RGB888UNPACK:
 	case PIXFMT_RGBA888:
-		rbswap = !(link_config & 0x1);
+		rbswap = 1;
 		break;
 	case PIXFMT_VYUY:
 	case PIXFMT_YVU422P:
 	case PIXFMT_YVU420P:
-		rbswap = link_config & 0x1;
 		uvswap = 1;
 		break;
 	case PIXFMT_YUYV:
-		rbswap = link_config & 0x1;
 		yuvswap = 1;
 		break;
 	default:
-		rbswap = link_config & 0x1;
 		break;
 	}
 
 	switch (pix_fmt) {
 	case PIXFMT_RGB565:
 	case PIXFMT_BGR565:
-		val = 0;
 		break;
 	case PIXFMT_RGB1555:
 	case PIXFMT_BGR1555:
@@ -263,6 +258,12 @@ static void path_set_mode(struct mmp_path *path, struct mmp_mode *mode)
 	tmp |= CFG_DUMB_ENA(1);
 	writel_relaxed(tmp, ctrl_regs(path) + intf_ctrl(path->id));
 
+	/* interface rb_swap setting */
+	tmp = readl_relaxed(ctrl_regs(path) + intf_rbswap_ctrl(path->id)) &
+		(~(CFG_INTFRBSWAP_MASK));
+	tmp |= link_config & CFG_INTFRBSWAP_MASK;
+	writel_relaxed(tmp, ctrl_regs(path) + intf_rbswap_ctrl(path->id));
+
 	writel_relaxed((mode->yres << 16) | mode->xres, &regs->screen_active);
 	writel_relaxed((mode->left_margin << 16) | mode->right_margin,
 		&regs->screen_h_porch);
drivers/video/mmp/hw/mmp_ctrl.h +4 -0
index edd2002..975d890 100644
@@ -163,6 +163,8 @@ struct lcd_regs {
 
 #define LCD_SCLK(path) ((PATH_PN == path->id) ? LCD_CFG_SCLK_DIV :\
 	((PATH_TV == path->id) ? LCD_TCLK_DIV : LCD_PN2_SCLK_DIV))
+#define intf_rbswap_ctrl(id)	((id) ? (((id) & 1) ? LCD_TVIF_CTRL : \
+				PN2_IOPAD_CONTROL) : LCD_TOP_CTRL)
 
 /* dither configure */
 #ifdef CONFIG_CPU_PXA988
@@ -615,6 +617,8 @@ struct lcd_regs {
 #define LCD_SPU_DUMB_CTRL			0x01B8
 #define	 CFG_DUMBMODE(mode)			((mode)<<28)
 #define	 CFG_DUMBMODE_MASK			0xF0000000
+#define	 CFG_INTFRBSWAP(mode)			((mode)<<24)
+#define	 CFG_INTFRBSWAP_MASK			0x0F000000
 #define	 CFG_LCDGPIO_O(data)			((data)<<20)
 #define	 CFG_LCDGPIO_O_MASK			0x0FF00000
 #define	 CFG_LCDGPIO_ENA(gpio)			((gpio)<<12)
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH v2 1/7 video: mmp: rb swap setting update for new LCD driver

Quoted 5 lines · Jett.Zhou

From: Guoqing Li <[email protected]>

We could set rb swap in two modules: DMA controler and interface output after blending.
This patch move the panel rbswap requirement setting in later module.

link_config originates from the platform's path config. link_config is undocumented and this patch also changes its meaning.

Previously, bit 0 triggered rbswap, and this behaviour is relied upon by arch/arm/mach-mmp/ttc_dkb.c

Now bits 27:24 of link_config are used to enable or disable rbswap, and link_config bit 0 is ignored. According to the specs for the panel path register, valid values for these new bits are 0 (no swap) and 1 (swap). ttc_dkb has not been updated in this patch series for this new behaviour.

I don't understand why rbswap is set to 1 in fmt_to_reg for certain RGB formats. The patch description suggests that the rb swapping can either be set in fmt_to_reg context (to be written into DMA controller) *or* in the interface output. If we are now relying on the interface output control to do RB swapping when appropriate, why are there still cases when we ask the DMA controller to do the same thing?

I also do not fully understand the requirement for RB swapping. I do understand that it changes pixel format from RGB to BGR. What is the point? I can imagine that some panels may require such a pixel format, however in that case, this configuration should be part of the panel configuration, not part of the path configuration as it currently is.

Daniel

#2 lore raw

PATCH v2 1/7 video: mmp: rb swap setting update for new LCD driver

2013/6/22 Daniel Drake <[email protected]>:

Quoted 26 lines · Jett.Zhou
Quoted 5 lines

From: Guoqing Li <[email protected]>

We could set rb swap in two modules: DMA controler and interface output after blending.
This patch move the panel rbswap requirement setting in later module.

link_config originates from the platform's path config. link_config is undocumented and this patch also changes its meaning.

Previously, bit 0 triggered rbswap, and this behaviour is relied upon by arch/arm/mach-mmp/ttc_dkb.c

Now bits 27:24 of link_config are used to enable or disable rbswap, and link_config bit 0 is ignored. According to the specs for the panel path register, valid values for these new bits are 0 (no swap) and 1 (swap). ttc_dkb has not been updated in this patch series for this new behaviour.

I don't understand why rbswap is set to 1 in fmt_to_reg for certain RGB formats. The patch description suggests that the rb swapping can either be set in fmt_to_reg context (to be written into DMA controller) *or* in the interface output. If we are now relying on the interface output control to do RB swapping when appropriate, why are there still cases when we ask the DMA controller to do the same thing?

Quoted 7 lines

I also do not fully understand the requirement for RB swapping. I do understand that it changes pixel format from RGB to BGR. What is the point? I can imagine that some panels may require such a pixel format, however in that case, this configuration should be part of the panel configuration, not part of the path configuration as it currently is.

Daniel

Hi Daniel
Sorry that the comments of the patch is not so clear. As you might know,We can set two rbswap setting, one is based
on pix_fmt to set into DMA input part, the other is to configured in the output interface part.
This patch include below change and enhancement:
1) The input format which support rbswap is based RGB format,
YUV series did not support now. So you can see the patch will change the rbswap value based on specific RGB format,eg. RGB will set rbswap = 1, BGR will not set it.
This part setting is controlled in driver internally, will
not depend on platform configure(link_config) any more.
2) The output part of rbswap is depend on link_config which is
defined in specific platfrom.

           It will setting bit27:24 of 0x01DC register, eg. DSI output

interface can be controlled by this.
TTC_dkb does not support dsi, the link_config is no used anymore.
I will add more this comments in the patch of V3.
Thanks

--

----------------------------------
Best Regards
Jett Zhou

A message that is not in the archive (sent off-list or not yet received): CACDDiy8=WRmnGMFr55uVWUE6+NNy3pMCeBfV8E9urAeW6VVEMw@mail.gmail.com

#4 lore raw

PATCH v2 1/7 video: mmp: rb swap setting update for new LCD driver

Quoted 9 lines · jett zhou

Sorry that the comments of the patch is not so clear.
As you might know,We can set two rbswap setting, one is based on
pix_fmt to set into DMA input part, the other is to configured in the output interface part.
This patch include below change and enhancement:
1) The input format which support rbswap is based RGB format, YUV
series did not support now. So you can see the patch will change the rbswap value based on specific RGB format,eg. RGB will set rbswap = 1, BGR will not set it.

What if I'm working with a display that doesn't need or want RB swapping? Lets say I am working with format PIXFMT_RGB565, and running your patch. dmafetch_set_fmt() gets called, and fmt_to_reg() sets rbswap to 1.
This means that dmafetch_set_fmt() writes a '1' into the appropriate RB-swapping bit in the LCD_PN_CTRL0 register, and this triggers the "DMA input" swapping that you mentioned. But I never asked for RB swapping...

Quoted 2 lines

This part setting is controlled in driver internally, will not
depend on platform configure(link_config) any more.

Your patch seems to depend very clearly on link_config.

Quoted 4 lines

2) The output part of rbswap is depend on link_config which is
defined in specific platfrom.

           It will setting bit27:24 of 0x01DC register, eg. DSI output

interface can be controlled by this.

I don't think you should add more disorganised/undocumented (ab)use of this magic link_config variable. You should create new, dedicated, documented fields.

Your comment above suggests that this RB-swapping behaviour is something that is imposed by the output device. In which case, this should be a configuration parameter on the panel, not on the path structure.

Quoted 1 line

TTC_dkb does not support dsi, the link_config is no used anymore.

Then you should fix up ttc_dkb before submitting this patch.

Thanks
Daniel

#5 lore raw

PATCH v2 1/7 video: mmp: rb swap setting update for new LCD driver

2013/6/24 Daniel Drake <[email protected]>:

Quoted 11 lines · jett zhou
Quoted 9 lines

Sorry that the comments of the patch is not so clear.
As you might know,We can set two rbswap setting, one is based on
pix_fmt to set into DMA input part, the other is to configured in the output interface part.
This patch include below change and enhancement:
1) The input format which support rbswap is based RGB format, YUV
series did not support now. So you can see the patch will change the rbswap value based on specific RGB format,eg. RGB will set rbswap = 1, BGR will not set it.

Quoted 8 lines

What if I'm working with a display that doesn't need or want RB swapping? Lets say I am working with format PIXFMT_RGB565, and running your patch. dmafetch_set_fmt() gets called, and fmt_to_reg() sets rbswap to 1.
This means that dmafetch_set_fmt() writes a '1' into the appropriate RB-swapping bit in the LCD_PN_CTRL0 register, and this triggers the "DMA input" swapping that you mentioned. But I never asked for RB swapping...

Yes, if you configure it as PIXFMT_RGB565, it will set rbswap in "DMA input" part.
So, for your case, you need to use PIXFMT_BGR565 instead of PIXFMT_RGB565.

Quoted 5 lines
Quoted 3 lines

This part setting is controlled in driver internally, will not
depend on platform configure(link_config) any more.

Your patch seems to depend very clearly on link_config.

Based on the patch, it does not depend on link_config for the "DMA input" swapping, it depend on the configured pix_format.

Quoted 9 lines
Quoted 5 lines

2) The output part of rbswap is depend on link_config which is
defined in specific platfrom.

           It will setting bit27:24 of 0x01DC register, eg. DSI output

interface can be controlled by this.

I don't think you should add more disorganised/undocumented (ab)use of this magic link_config variable. You should create new, dedicated, documented fields.

Agree with you, create new,dedicated field for this usage is better, I will amend the patch and send out for review again.:)

Quoted 9 lines

Your comment above suggests that this RB-swapping behaviour is something that is imposed by the output device. In which case, this should be a configuration parameter on the panel, not on the path structure.

Quoted 1 line

TTC_dkb does not support dsi, the link_config is no used anymore.

Then you should fix up ttc_dkb before submitting this patch.

After we add one new field for this output rbswap setting based on dsi interface, it can be used by new stepping of mmp display controller, ttc_dkb platform just leave and not touch it, it will be tranparent for ttc_dkb, does not need to nothing for platform configuration for ttc_dkb usage.
It means , ttc_dkb can only configure rbswap in "dma input" part, not support rbswap in dsi interface part.
What do you think?

Thanks

--

----------------------------------
Best Regards
Jett Zhou

#6 lore raw

PATCH v2 1/7 video: mmp: rb swap setting update for new LCD driver

Quoted 9 lines · jett zhou
Quoted 8 lines

What if I'm working with a display that doesn't need or want RB swapping? Lets say I am working with format PIXFMT_RGB565, and running your patch. dmafetch_set_fmt() gets called, and fmt_to_reg() sets rbswap to 1.
This means that dmafetch_set_fmt() writes a '1' into the appropriate RB-swapping bit in the LCD_PN_CTRL0 register, and this triggers the "DMA input" swapping that you mentioned. But I never asked for RB swapping...

Quoted 3 lines

Yes, if you configure it as PIXFMT_RGB565, it will set rbswap in "DMA input" part.
So, for your case, you need to use PIXFMT_BGR565 instead of PIXFMT_RGB565.

So let me get this straight. I have a display that wants RGB565 format, no RB swapping. I don't do anything special in link_config to affect any swapping.

After your patch, I must request BGR565 format in order to get RGB565? That sounds backwards to me.

Quoted 9 lines
Quoted 8 lines

Your comment above suggests that this RB-swapping behaviour is something that is imposed by the output device. In which case, this should be a configuration parameter on the panel, not on the path structure.

Quoted 1 line

TTC_dkb does not support dsi, the link_config is no used anymore.

Then you should fix up ttc_dkb before submitting this patch.

Quoted 8 lines

After we add one new field for this output rbswap setting based on dsi interface, it can be used by new stepping of mmp display controller, ttc_dkb platform just leave and not touch it, it will be tranparent for ttc_dkb, does not need to nothing for platform configuration for ttc_dkb usage.
It means , ttc_dkb can only configure rbswap in "dma input" part, not support rbswap in dsi interface part.
What do you think?

The point I am trying to make is that your patch is changing behaviour for ttc_dkb, so you need to address that at the same time.

Right now ttc_dkb does this:

#define CFG_GRA_SWAPRB(x) (x << 0) /* 1: rbswap enabled */
.link_config = CFG_DUMBMODE(0x2) | CFG_GRA_SWAPRB(0x1),

i.e. SWAPRB requested through bit 0 in link_config

And this is obeyed by the existing code in fmt_to_reg:

   u32 link_config = path_to_path_plat(overlay->path)->link_config;
   rbswap = link_config & 0x1;

Your patch removes the handling of link_config bit 0, without fixing up its only user (even if that user was incorrect). That is not good practice.

Another question: why is this change needed?
We can request rb swapping either in DMA input or in the output interface. I can understand the driver maybe supporting one option or the other. But after your patch, it seems like both are supported: RB swapping could be enabled either through choice of input format, or through configuration of output parameters.

Daniel

#7 lore raw

PATCH v2 1/7 video: mmp: rb swap setting update for new LCD driver

2013/6/25 Daniel Drake <[email protected]>:

Quoted 14 lines · jett zhou
Quoted 9 lines
Quoted 8 lines

What if I'm working with a display that doesn't need or want RB swapping? Lets say I am working with format PIXFMT_RGB565, and running your patch. dmafetch_set_fmt() gets called, and fmt_to_reg() sets rbswap to 1.
This means that dmafetch_set_fmt() writes a '1' into the appropriate RB-swapping bit in the LCD_PN_CTRL0 register, and this triggers the "DMA input" swapping that you mentioned. But I never asked for RB swapping...

Quoted 3 lines

Yes, if you configure it as PIXFMT_RGB565, it will set rbswap in "DMA input" part.
So, for your case, you need to use PIXFMT_BGR565 instead of PIXFMT_RGB565.

Quoted 6 lines

So let me get this straight. I have a display that wants RGB565 format, no RB swapping. I don't do anything special in link_config to affect any swapping.

After your patch, I must request BGR565 format in order to get RGB565? That sounds backwards to me.

HI Daniel
My above explanation may be not so precise and correct, actually
you can RGB565 directly and does not need BGR565, mmp display controller handle it accordingly in driver.
Take RGB565 and BGR565 as example:
RGB565 indicates the source data in memory is that Red is
[15~11] , Green is [10~5], Blue is [4:0], Red is MSB, Blue is LSB, but for the display dma input default setting(rbswap = 0), it only support Blue is [15~11] , Green is [10~5], Red is [4:0], Red is LSB, Blue is MSB, so for this format(RGB565), display controller need to set rbswap = 1 and it can support the MSB/LSB correctly.
In conclusion, no matter you use RGB565 or BGR565, mmp
display driver did the rbswap setiing based on the format and what is MSB/LSB, so platform does not need handle it by link_config based on this patch.
Thanks

Quoted 38 lines
Quoted 10 lines
Quoted 9 lines

Your comment above suggests that this RB-swapping behaviour is something that is imposed by the output device. In which case, this should be a configuration parameter on the panel, not on the path structure.

Quoted 1 line

TTC_dkb does not support dsi, the link_config is no used anymore.

Then you should fix up ttc_dkb before submitting this patch.

Quoted 8 lines

After we add one new field for this output rbswap setting based on dsi interface, it can be used by new stepping of mmp display controller, ttc_dkb platform just leave and not touch it, it will be tranparent for ttc_dkb, does not need to nothing for platform configuration for ttc_dkb usage.
It means , ttc_dkb can only configure rbswap in "dma input" part, not support rbswap in dsi interface part.
What do you think?

The point I am trying to make is that your patch is changing behaviour for ttc_dkb, so you need to address that at the same time.

Right now ttc_dkb does this:

#define CFG_GRA_SWAPRB(x) (x << 0) /* 1: rbswap enabled */
.link_config = CFG_DUMBMODE(0x2) | CFG_GRA_SWAPRB(0x1),

i.e. SWAPRB requested through bit 0 in link_config

And this is obeyed by the existing code in fmt_to_reg:

   u32 link_config = path_to_path_plat(overlay->path)->link_config;
   rbswap = link_config & 0x1;

Your patch removes the handling of link_config bit 0, without fixing up its only user (even if that user was incorrect). That is not good practice.

Quoted 6 lines

Another question: why is this change needed?
We can request rb swapping either in DMA input or in the output interface. I can understand the driver maybe supporting one option or the other. But after your patch, it seems like both are supported: RB swapping could be enabled either through choice of input format, or through configuration of output parameters.

For TTC dkb, you are right, I need to fix the rbswap in the platform part, I will add one fix patch for ttc_dkb based on new rbswap patch. For output dsi interface, it has this feature to do rbswap again if it needs specifc byte sequence of RGB byte of DSI panel.
eg. If display content is set RGB565 in memory and DMA input part set rbswap in driver to support Red as MSB , Blue LSB, but dsi panel only support Red as LSB, Blue as MSB, then it can use this feature.
If there is no this requirement of panel, this dsi output part is not needed.

Thanks

Quoted 1 line

--

----------------------------------
Best Regards
Jett Zhou