diff mbox series

[v2,05/19] videomodes: add helper function to convert from ctfb to display_timing

Message ID 20200322224435.114512-6-giulio.benetti@benettiengineering.com
State Superseded
Headers show
Series i.MXRT1050 add LCDIF support | expand

Commit Message

Giulio Benetti March 22, 2020, 10:44 p.m. UTC
This function converts from "struct ctf_res_modes" to
"struct display_timing".

Signed-off-by: Giulio Benetti <giulio.benetti at benettiengineering.com>
---
 drivers/video/videomodes.c | 29 +++++++++++++++++++++++++++++
 drivers/video/videomodes.h |  3 +++
 2 files changed, 32 insertions(+)

Comments

Simon Glass March 23, 2020, 3:36 p.m. UTC | #1
Hi Giulio,

On Sun, 22 Mar 2020 at 16:44, Giulio Benetti
<giulio.benetti at benettiengineering.com> wrote:
>
> This function converts from "struct ctf_res_modes" to
> "struct display_timing".
>
> Signed-off-by: Giulio Benetti <giulio.benetti at benettiengineering.com>
> ---
>  drivers/video/videomodes.c | 29 +++++++++++++++++++++++++++++
>  drivers/video/videomodes.h |  3 +++
>  2 files changed, 32 insertions(+)
>
> diff --git a/drivers/video/videomodes.c b/drivers/video/videomodes.c
> index ac25b45f81..89003eea72 100644
> --- a/drivers/video/videomodes.c
> +++ b/drivers/video/videomodes.c
> @@ -444,3 +444,32 @@ int video_edid_dtd_to_ctfb_res_modes(struct edid_detailed_timing *t,
>
>         return 0;
>  }
> +
> +void video_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
> +                                      struct display_timing *timing)
> +{
> +       timing->pixelclock.typ = mode->pixclock_khz * 1000;
> +
> +       timing->hactive.typ = mode->xres;
> +       timing->hfront_porch.typ = mode->right_margin;
> +       timing->hback_porch.typ = mode->left_margin;
> +       timing->hsync_len.typ = mode->hsync_len;
> +
> +       timing->vactive.typ = mode->yres;
> +       timing->vfront_porch.typ = mode->lower_margin;
> +       timing->vback_porch.typ = mode->upper_margin;
> +       timing->vsync_len.typ = mode->vsync_len;
> +
> +       timing->flags = 0;
> +
> +       if (mode->sync & FB_SYNC_HOR_HIGH_ACT)
> +               timing->flags |= DISPLAY_FLAGS_HSYNC_HIGH;
> +       else
> +               timing->flags |= DISPLAY_FLAGS_HSYNC_LOW;
> +       if (mode->sync & FB_SYNC_VERT_HIGH_ACT)
> +               timing->flags |= DISPLAY_FLAGS_VSYNC_HIGH;
> +       else
> +               timing->flags |= DISPLAY_FLAGS_VSYNC_LOW;
> +       if (mode->vmode == FB_VMODE_INTERLACED)
> +               timing->flags |= DISPLAY_FLAGS_INTERLACED;
> +}
> diff --git a/drivers/video/videomodes.h b/drivers/video/videomodes.h
> index 29a3db4ae3..6713f96d19 100644
> --- a/drivers/video/videomodes.h
> +++ b/drivers/video/videomodes.h
> @@ -92,3 +92,6 @@ int video_get_option_int(const char *options, const char *name, int def);
>
>  int video_edid_dtd_to_ctfb_res_modes(struct edid_detailed_timing *t,
>                                      struct ctfb_res_modes *mode);
> +
> +void video_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
> +                                      struct display_timing *timing);

Please add a comment for this. What is ctfb?

Regards,
Simon
>
Giulio Benetti March 23, 2020, 4 p.m. UTC | #2
On 3/23/20 4:36 PM, Simon Glass wrote:
> Hi Giulio,
> 
> On Sun, 22 Mar 2020 at 16:44, Giulio Benetti
> <giulio.benetti at benettiengineering.com> wrote:
>>
>> This function converts from "struct ctf_res_modes" to
>> "struct display_timing".
>>
>> Signed-off-by: Giulio Benetti <giulio.benetti at benettiengineering.com>
>> ---
>>   drivers/video/videomodes.c | 29 +++++++++++++++++++++++++++++
>>   drivers/video/videomodes.h |  3 +++
>>   2 files changed, 32 insertions(+)
>>
>> diff --git a/drivers/video/videomodes.c b/drivers/video/videomodes.c
>> index ac25b45f81..89003eea72 100644
>> --- a/drivers/video/videomodes.c
>> +++ b/drivers/video/videomodes.c
>> @@ -444,3 +444,32 @@ int video_edid_dtd_to_ctfb_res_modes(struct edid_detailed_timing *t,
>>
>>          return 0;
>>   }
>> +
>> +void video_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
>> +                                      struct display_timing *timing)
>> +{
>> +       timing->pixelclock.typ = mode->pixclock_khz * 1000;
>> +
>> +       timing->hactive.typ = mode->xres;
>> +       timing->hfront_porch.typ = mode->right_margin;
>> +       timing->hback_porch.typ = mode->left_margin;
>> +       timing->hsync_len.typ = mode->hsync_len;
>> +
>> +       timing->vactive.typ = mode->yres;
>> +       timing->vfront_porch.typ = mode->lower_margin;
>> +       timing->vback_porch.typ = mode->upper_margin;
>> +       timing->vsync_len.typ = mode->vsync_len;
>> +
>> +       timing->flags = 0;
>> +
>> +       if (mode->sync & FB_SYNC_HOR_HIGH_ACT)
>> +               timing->flags |= DISPLAY_FLAGS_HSYNC_HIGH;
>> +       else
>> +               timing->flags |= DISPLAY_FLAGS_HSYNC_LOW;
>> +       if (mode->sync & FB_SYNC_VERT_HIGH_ACT)
>> +               timing->flags |= DISPLAY_FLAGS_VSYNC_HIGH;
>> +       else
>> +               timing->flags |= DISPLAY_FLAGS_VSYNC_LOW;
>> +       if (mode->vmode == FB_VMODE_INTERLACED)
>> +               timing->flags |= DISPLAY_FLAGS_INTERLACED;
>> +}
>> diff --git a/drivers/video/videomodes.h b/drivers/video/videomodes.h
>> index 29a3db4ae3..6713f96d19 100644
>> --- a/drivers/video/videomodes.h
>> +++ b/drivers/video/videomodes.h
>> @@ -92,3 +92,6 @@ int video_get_option_int(const char *options, const char *name, int def);
>>
>>   int video_edid_dtd_to_ctfb_res_modes(struct edid_detailed_timing *t,
>>                                       struct ctfb_res_modes *mode);
>> +
>> +void video_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
>> +                                      struct display_timing *timing);
> 
> Please add a comment for this. 

Ok

> What is ctfb?

If I'm not wrong it should stand for "Cathode Tube Frame Buffer" and it 
describes a Display(old Cathode Tube) Frame Buffer. This is at least 
what I've deducted :-)

Thanks for reviewing and
Best regards
Simon Glass March 23, 2020, 6:42 p.m. UTC | #3
Hi Giulio,

On Mon, 23 Mar 2020 at 10:00, Giulio Benetti
<giulio.benetti at benettiengineering.com> wrote:
>
> On 3/23/20 4:36 PM, Simon Glass wrote:
> > Hi Giulio,
> >
> > On Sun, 22 Mar 2020 at 16:44, Giulio Benetti
> > <giulio.benetti at benettiengineering.com> wrote:
> >>
> >> This function converts from "struct ctf_res_modes" to
> >> "struct display_timing".
> >>
> >> Signed-off-by: Giulio Benetti <giulio.benetti at benettiengineering.com>
> >> ---
> >>   drivers/video/videomodes.c | 29 +++++++++++++++++++++++++++++
> >>   drivers/video/videomodes.h |  3 +++
> >>   2 files changed, 32 insertions(+)
> >>
> >> diff --git a/drivers/video/videomodes.c b/drivers/video/videomodes.c
> >> index ac25b45f81..89003eea72 100644
> >> --- a/drivers/video/videomodes.c
> >> +++ b/drivers/video/videomodes.c
> >> @@ -444,3 +444,32 @@ int video_edid_dtd_to_ctfb_res_modes(struct edid_detailed_timing *t,
> >>
> >>          return 0;
> >>   }
> >> +
> >> +void video_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
> >> +                                      struct display_timing *timing)
> >> +{
> >> +       timing->pixelclock.typ = mode->pixclock_khz * 1000;
> >> +
> >> +       timing->hactive.typ = mode->xres;
> >> +       timing->hfront_porch.typ = mode->right_margin;
> >> +       timing->hback_porch.typ = mode->left_margin;
> >> +       timing->hsync_len.typ = mode->hsync_len;
> >> +
> >> +       timing->vactive.typ = mode->yres;
> >> +       timing->vfront_porch.typ = mode->lower_margin;
> >> +       timing->vback_porch.typ = mode->upper_margin;
> >> +       timing->vsync_len.typ = mode->vsync_len;
> >> +
> >> +       timing->flags = 0;
> >> +
> >> +       if (mode->sync & FB_SYNC_HOR_HIGH_ACT)
> >> +               timing->flags |= DISPLAY_FLAGS_HSYNC_HIGH;
> >> +       else
> >> +               timing->flags |= DISPLAY_FLAGS_HSYNC_LOW;
> >> +       if (mode->sync & FB_SYNC_VERT_HIGH_ACT)
> >> +               timing->flags |= DISPLAY_FLAGS_VSYNC_HIGH;
> >> +       else
> >> +               timing->flags |= DISPLAY_FLAGS_VSYNC_LOW;
> >> +       if (mode->vmode == FB_VMODE_INTERLACED)
> >> +               timing->flags |= DISPLAY_FLAGS_INTERLACED;
> >> +}
> >> diff --git a/drivers/video/videomodes.h b/drivers/video/videomodes.h
> >> index 29a3db4ae3..6713f96d19 100644
> >> --- a/drivers/video/videomodes.h
> >> +++ b/drivers/video/videomodes.h
> >> @@ -92,3 +92,6 @@ int video_get_option_int(const char *options, const char *name, int def);
> >>
> >>   int video_edid_dtd_to_ctfb_res_modes(struct edid_detailed_timing *t,
> >>                                       struct ctfb_res_modes *mode);
> >> +
> >> +void video_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
> >> +                                      struct display_timing *timing);
> >
> > Please add a comment for this.
>
> Ok
>
> > What is ctfb?
>
> If I'm not wrong it should stand for "Cathode Tube Frame Buffer" and it
> describes a Display(old Cathode Tube) Frame Buffer. This is at least
> what I've deducted :-)

OK certainly plausible! Then you should add it to your comment somewhere.

Regards,
Simon
Giulio Benetti March 23, 2020, 7 p.m. UTC | #4
On 3/23/20 7:42 PM, Simon Glass wrote:
> Hi Giulio,
> 
> On Mon, 23 Mar 2020 at 10:00, Giulio Benetti
> <giulio.benetti at benettiengineering.com> wrote:
>>
>> On 3/23/20 4:36 PM, Simon Glass wrote:
>>> Hi Giulio,
>>>
>>> On Sun, 22 Mar 2020 at 16:44, Giulio Benetti
>>> <giulio.benetti at benettiengineering.com> wrote:
>>>>
>>>> This function converts from "struct ctf_res_modes" to
>>>> "struct display_timing".
>>>>
>>>> Signed-off-by: Giulio Benetti <giulio.benetti at benettiengineering.com>
>>>> ---
>>>>    drivers/video/videomodes.c | 29 +++++++++++++++++++++++++++++
>>>>    drivers/video/videomodes.h |  3 +++
>>>>    2 files changed, 32 insertions(+)
>>>>
>>>> diff --git a/drivers/video/videomodes.c b/drivers/video/videomodes.c
>>>> index ac25b45f81..89003eea72 100644
>>>> --- a/drivers/video/videomodes.c
>>>> +++ b/drivers/video/videomodes.c
>>>> @@ -444,3 +444,32 @@ int video_edid_dtd_to_ctfb_res_modes(struct edid_detailed_timing *t,
>>>>
>>>>           return 0;
>>>>    }
>>>> +
>>>> +void video_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
>>>> +                                      struct display_timing *timing)
>>>> +{
>>>> +       timing->pixelclock.typ = mode->pixclock_khz * 1000;
>>>> +
>>>> +       timing->hactive.typ = mode->xres;
>>>> +       timing->hfront_porch.typ = mode->right_margin;
>>>> +       timing->hback_porch.typ = mode->left_margin;
>>>> +       timing->hsync_len.typ = mode->hsync_len;
>>>> +
>>>> +       timing->vactive.typ = mode->yres;
>>>> +       timing->vfront_porch.typ = mode->lower_margin;
>>>> +       timing->vback_porch.typ = mode->upper_margin;
>>>> +       timing->vsync_len.typ = mode->vsync_len;
>>>> +
>>>> +       timing->flags = 0;
>>>> +
>>>> +       if (mode->sync & FB_SYNC_HOR_HIGH_ACT)
>>>> +               timing->flags |= DISPLAY_FLAGS_HSYNC_HIGH;
>>>> +       else
>>>> +               timing->flags |= DISPLAY_FLAGS_HSYNC_LOW;
>>>> +       if (mode->sync & FB_SYNC_VERT_HIGH_ACT)
>>>> +               timing->flags |= DISPLAY_FLAGS_VSYNC_HIGH;
>>>> +       else
>>>> +               timing->flags |= DISPLAY_FLAGS_VSYNC_LOW;
>>>> +       if (mode->vmode == FB_VMODE_INTERLACED)
>>>> +               timing->flags |= DISPLAY_FLAGS_INTERLACED;
>>>> +}
>>>> diff --git a/drivers/video/videomodes.h b/drivers/video/videomodes.h
>>>> index 29a3db4ae3..6713f96d19 100644
>>>> --- a/drivers/video/videomodes.h
>>>> +++ b/drivers/video/videomodes.h
>>>> @@ -92,3 +92,6 @@ int video_get_option_int(const char *options, const char *name, int def);
>>>>
>>>>    int video_edid_dtd_to_ctfb_res_modes(struct edid_detailed_timing *t,
>>>>                                        struct ctfb_res_modes *mode);
>>>> +
>>>> +void video_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
>>>> +                                      struct display_timing *timing);
>>>
>>> Please add a comment for this.
>>
>> Ok
>>
>>> What is ctfb?
>>
>> If I'm not wrong it should stand for "Cathode Tube Frame Buffer" and it
>> describes a Display(old Cathode Tube) Frame Buffer. This is at least
>> what I've deducted :-)
> 
> OK certainly plausible! Then you should add it to your comment somewhere.

Perfect, done while describing what functions does in Doxygen style!

Best regards
diff mbox series

Patch

diff --git a/drivers/video/videomodes.c b/drivers/video/videomodes.c
index ac25b45f81..89003eea72 100644
--- a/drivers/video/videomodes.c
+++ b/drivers/video/videomodes.c
@@ -444,3 +444,32 @@  int video_edid_dtd_to_ctfb_res_modes(struct edid_detailed_timing *t,
 
 	return 0;
 }
+
+void video_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
+				       struct display_timing *timing)
+{
+	timing->pixelclock.typ = mode->pixclock_khz * 1000;
+
+	timing->hactive.typ = mode->xres;
+	timing->hfront_porch.typ = mode->right_margin;
+	timing->hback_porch.typ = mode->left_margin;
+	timing->hsync_len.typ = mode->hsync_len;
+
+	timing->vactive.typ = mode->yres;
+	timing->vfront_porch.typ = mode->lower_margin;
+	timing->vback_porch.typ = mode->upper_margin;
+	timing->vsync_len.typ = mode->vsync_len;
+
+	timing->flags = 0;
+
+	if (mode->sync & FB_SYNC_HOR_HIGH_ACT)
+		timing->flags |= DISPLAY_FLAGS_HSYNC_HIGH;
+	else
+		timing->flags |= DISPLAY_FLAGS_HSYNC_LOW;
+	if (mode->sync & FB_SYNC_VERT_HIGH_ACT)
+		timing->flags |= DISPLAY_FLAGS_VSYNC_HIGH;
+	else
+		timing->flags |= DISPLAY_FLAGS_VSYNC_LOW;
+	if (mode->vmode == FB_VMODE_INTERLACED)
+		timing->flags |= DISPLAY_FLAGS_INTERLACED;
+}
diff --git a/drivers/video/videomodes.h b/drivers/video/videomodes.h
index 29a3db4ae3..6713f96d19 100644
--- a/drivers/video/videomodes.h
+++ b/drivers/video/videomodes.h
@@ -92,3 +92,6 @@  int video_get_option_int(const char *options, const char *name, int def);
 
 int video_edid_dtd_to_ctfb_res_modes(struct edid_detailed_timing *t,
 				     struct ctfb_res_modes *mode);
+
+void video_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
+				       struct display_timing *timing);