On Wed, 2012-01-04 at 16:39 +0530, [email protected] wrote:
> From: Mythri P K <[email protected]>
> 
> Change the timing match logic, Instead of the statically mapped method
> to get the corresponding timings for a given code and mode, move to a
> simpler array indexed method. It  will help to scale up to add more
> timings when needed.
> 
> Signed-off-by: Mythri P K <[email protected]>
> ---
>  drivers/video/omap2/dss/hdmi.c |  177 +++++++++++++++++----------------------
>  1 files changed, 77 insertions(+), 100 deletions(-)

> -static int get_timings_index(void)
> +static const struct hdmi_config *hdmi_find_timing(
> +                                     const struct hdmi_config *timings_arr,
> +                                     int len)
>  {
> -     int code;
> +     int i;
> +     const struct hdmi_config *timing = NULL;
>  
> -     if (hdmi.mode == 0)
> -             code = code_vesa[hdmi.code];
> -     else
> -             code = code_cea[hdmi.code];
> +     for (i = 0; i < len; i++) {
> +             if (timings_arr[i].cm.code == hdmi.code) {
> +                     timing = &timings_arr[i];
> +                     return timing;
> +             }
> +     }
> +     return timing;

You don't need the timing variable at all. Just return &timings_arr[i]
or NULL.
 
> @@ -341,9 +312,15 @@ static int hdmi_power_on(struct omap_dss_device *dssdev)
>               dssdev->panel.timings.x_res,
>               dssdev->panel.timings.y_res);
>  
> -     code = get_timings_index();
> -     update_hdmi_timings(&hdmi.ip_data.cfg, p, code);
> -
> +     if (hdmi_get_timings() == NULL) {
> +             /* HDMI code 4 corresponds to 640 * 480 VGA */
> +             hdmi.code = 4;
> +             /* DVI mode 1 corresponds to HDMI 0 to DVI */
> +             hdmi.mode = HDMI_DVI;
> +             hdmi.ip_data.cfg = vesa_timings[0];
> +     } else {
> +             hdmi.ip_data.cfg = *(hdmi_get_timings());
> +     }

Now you are searching for the timings twice... Do:

timings = hdmi_get_timings();

if (timings == NULL) {
        /* default to VGA */
        ...
} else {
        hdmi.ip_data.cfg = *timings;
}

 Tomi

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to