All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomasz Stanislawski <t.stanislaws@samsung.com>
Cc: linux-media@vger.kernel.org, sachin.kamat@linaro.org,
	m.szyprowski@samsung.com, kyungmin.park@samsung.com,
	hverkuil@xs4all.nl
Subject: Re: [PATCH 2/6] v4l: s5p-tv: hdmiphy: add support for per-platform variants
Date: Wed, 14 Mar 2012 02:13:10 +0100	[thread overview]
Message-ID: <1720743.tF7fzoSFyt@avalon> (raw)
In-Reply-To: <1331645714-24535-3-git-send-email-t.stanislaws@samsung.com>

Hi Tomasz,

Thanks for the patch.

On Tuesday 13 March 2012 14:35:10 Tomasz Stanislawski wrote:
> Adds selection of HDMIPHY configuration tables basing on both preset and
> platform variant.
> 
> Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
>  drivers/media/video/s5p-tv/hdmiphy_drv.c |  227 +++++++++++++++++++++------
> 1 files changed, 187 insertions(+), 40
> deletions(-)
> 
> diff --git a/drivers/media/video/s5p-tv/hdmiphy_drv.c
> b/drivers/media/video/s5p-tv/hdmiphy_drv.c index 0afef77..7ab00fd 100644
> --- a/drivers/media/video/s5p-tv/hdmiphy_drv.c
> +++ b/drivers/media/video/s5p-tv/hdmiphy_drv.c
> @@ -25,54 +25,186 @@ MODULE_AUTHOR("Tomasz Stanislawski
> <t.stanislaws@samsung.com>"); MODULE_DESCRIPTION("Samsung HDMI Physical
> interface driver");
>  MODULE_LICENSE("GPL");
> 
> -struct hdmiphy_conf {
> -	u32 preset;
> -	const u8 *data;
> +enum hdmiphy_id {
> +	HDMIPHY_S5PV210,
> +	HDMIPHY_EXYNOS4210,
> +	HDMIPHY_EXYNOS4212,
> +	HDMIPHY_EXYNOS4412,
>  };
> 
> -static const u8 hdmiphy_conf27[32] = {
> -	0x01, 0x05, 0x00, 0xD8, 0x10, 0x1C, 0x30, 0x40,
> -	0x6B, 0x10, 0x02, 0x51, 0xDf, 0xF2, 0x54, 0x87,
> -	0x84, 0x00, 0x30, 0x38, 0x00, 0x08, 0x10, 0xE0,
> -	0x22, 0x40, 0xe3, 0x26, 0x00, 0x00, 0x00, 0x00,
> -};
> -
> -static const u8 hdmiphy_conf74_175[32] = {
> -	0x01, 0x05, 0x00, 0xD8, 0x10, 0x9C, 0xef, 0x5B,
> -	0x6D, 0x10, 0x01, 0x51, 0xef, 0xF3, 0x54, 0xb9,
> -	0x84, 0x00, 0x30, 0x38, 0x00, 0x08, 0x10, 0xE0,
> -	0x22, 0x40, 0xa5, 0x26, 0x01, 0x00, 0x00, 0x00,
> +struct hdmiphy_conf {
> +	unsigned long pixclk;
> +	enum hdmiphy_id id;
> +	const u8 data[32];
>  };
> 
> -static const u8 hdmiphy_conf74_25[32] = {
> -	0x01, 0x05, 0x00, 0xd8, 0x10, 0x9c, 0xf8, 0x40,
> -	0x6a, 0x10, 0x01, 0x51, 0xff, 0xf1, 0x54, 0xba,
> -	0x84, 0x00, 0x30, 0x38, 0x00, 0x08, 0x10, 0xe0,
> -	0x22, 0x40, 0xa4, 0x26, 0x01, 0x00, 0x00, 0x00,
> +struct hdmiphy_ctx {
> +	struct v4l2_subdev sd;
> +	enum hdmiphy_id id;
>  };
> 
> -static const u8 hdmiphy_conf148_5[32] = {
> -	0x01, 0x05, 0x00, 0xD8, 0x10, 0x9C, 0xf8, 0x40,
> -	0x6A, 0x18, 0x00, 0x51, 0xff, 0xF1, 0x54, 0xba,
> -	0x84, 0x00, 0x10, 0x38, 0x00, 0x08, 0x10, 0xE0,
> -	0x22, 0x40, 0xa4, 0x26, 0x02, 0x00, 0x00, 0x00,
> -};
> +static inline  struct hdmiphy_ctx *sd_to_ctx(struct v4l2_subdev *sd)

s/inline  struct/inline struct/

> +{
> +	return container_of(sd, struct hdmiphy_ctx, sd);
> +}
> 
>  static const struct hdmiphy_conf hdmiphy_conf[] = {
> -	{ V4L2_DV_480P59_94, hdmiphy_conf27 },
> -	{ V4L2_DV_1080P30, hdmiphy_conf74_175 },
> -	{ V4L2_DV_720P59_94, hdmiphy_conf74_175 },
> -	{ V4L2_DV_720P60, hdmiphy_conf74_25 },
> -	{ V4L2_DV_1080P50, hdmiphy_conf148_5 },
> -	{ V4L2_DV_1080P60, hdmiphy_conf148_5 },
> +	{ .id = HDMIPHY_S5PV210, .pixclk = 27000000, .data = {
> +		0x01, 0x05, 0x00, 0xD8, 0x10, 0x1C, 0x30, 0x40,
> +		0x6B, 0x10, 0x02, 0x52, 0xDF, 0xF2, 0x54, 0x87,
> +		0x84, 0x00, 0x30, 0x38, 0x00, 0x08, 0x10, 0xE0,
> +		0x22, 0x40, 0xE3, 0x26, 0x00, 0x00, 0x00, 0x00, }
> +	},
> +	{ .id = HDMIPHY_S5PV210, .pixclk = 27027000, .data = {
> +		0x01, 0x05, 0x00, 0xD4, 0x10, 0x9C, 0x09, 0x64,
> +		0x6B, 0x10, 0x02, 0x52, 0xDF, 0xF2, 0x54, 0x87,
> +		0x84, 0x00, 0x30, 0x38, 0x00, 0x08, 0x10, 0xE0,
> +		0x22, 0x40, 0xE2, 0x26, 0x00, 0x00, 0x00, 0x00, }
> +	},
> +	{ .id = HDMIPHY_S5PV210, .pixclk = 74176000, .data = {
> +		0x01, 0x05, 0x00, 0xD8, 0x10, 0x9C, 0xEF, 0x5B,
> +		0x6D, 0x10, 0x01, 0x52, 0xEF, 0xF3, 0x54, 0xB9,
> +		0x84, 0x00, 0x30, 0x38, 0x00, 0x08, 0x10, 0xE0,
> +		0x22, 0x40, 0xA5, 0x26, 0x01, 0x00, 0x00, 0x00, }
> +	},
> +	{ .id = HDMIPHY_S5PV210, .pixclk = 74250000, .data = {
> +		0x01, 0x05, 0x00, 0xD8, 0x10, 0x9C, 0xF8, 0x40,
> +		0x6A, 0x10, 0x01, 0x52, 0xFF, 0xF1, 0x54, 0xBA,
> +		0x84, 0x00, 0x10, 0x38, 0x00, 0x08, 0x10, 0xE0,
> +		0x22, 0x40, 0xA4, 0x26, 0x01, 0x00, 0x00, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4210, .pixclk = 27000000, .data = {
> +		0x01, 0x05, 0x00, 0xD8, 0x10, 0x1C, 0x30, 0x40,
> +		0x6B, 0x10, 0x02, 0x51, 0xDF, 0xF2, 0x54, 0x87,
> +		0x84, 0x00, 0x30, 0x38, 0x00, 0x08, 0x10, 0xE0,
> +		0x22, 0x40, 0xE3, 0x26, 0x00, 0x00, 0x00, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4210, .pixclk = 27027000, .data = {
> +		0x01, 0x05, 0x00, 0xD4, 0x10, 0x9C, 0x09, 0x64,
> +		0x6B, 0x10, 0x02, 0x51, 0xDF, 0xF2, 0x54, 0x87,
> +		0x84, 0x00, 0x30, 0x38, 0x00, 0x08, 0x10, 0xE0,
> +		0x22, 0x40, 0xE2, 0x26, 0x00, 0x00, 0x00, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4210, .pixclk = 74176000, .data = {
> +		0x01, 0x05, 0x00, 0xD8, 0x10, 0x9C, 0xEF, 0x5B,
> +		0x6D, 0x10, 0x01, 0x51, 0xEF, 0xF3, 0x54, 0xB9,
> +		0x84, 0x00, 0x30, 0x38, 0x00, 0x08, 0x10, 0xE0,
> +		0x22, 0x40, 0xA5, 0x26, 0x01, 0x00, 0x00, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4210, .pixclk = 74250000, .data = {
> +		0x01, 0x05, 0x00, 0xD8, 0x10, 0x9C, 0xF8, 0x40,
> +		0x6A, 0x10, 0x01, 0x51, 0xFF, 0xF1, 0x54, 0xBA,
> +		0x84, 0x00, 0x10, 0x38, 0x00, 0x08, 0x10, 0xE0,
> +		0x22, 0x40, 0xA4, 0x26, 0x01, 0x00, 0x00, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4210, .pixclk = 148352000, .data = {
> +		0x01, 0x05, 0x00, 0xD8, 0x10, 0x9C, 0xEF, 0x5B,
> +		0x6D, 0x18, 0x00, 0x51, 0xEF, 0xF3, 0x54, 0xB9,
> +		0x84, 0x00, 0x30, 0x38, 0x00, 0x08, 0x10, 0xE0,
> +		0x11, 0x40, 0xA5, 0x26, 0x02, 0x00, 0x00, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4210, .pixclk = 148500000, .data = {
> +		0x01, 0x05, 0x00, 0xD8, 0x10, 0x9C, 0xF8, 0x40,
> +		0x6A, 0x18, 0x00, 0x51, 0xFF, 0xF1, 0x54, 0xBA,
> +		0x84, 0x00, 0x10, 0x38, 0x00, 0x08, 0x10, 0xE0,
> +		0x11, 0x40, 0xA4, 0x26, 0x02, 0x00, 0x00, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4212, .pixclk = 27000000, .data = {
> +		0x01, 0x11, 0x2D, 0x75, 0x00, 0x01, 0x00, 0x08,
> +		0x82, 0x00, 0x0E, 0xD9, 0x45, 0xA0, 0x34, 0xC0,
> +		0x0B, 0x80, 0x12, 0x87, 0x08, 0x24, 0x24, 0x71,
> +		0x54, 0xE3, 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4212, .pixclk = 27027000, .data = {
> +		0x01, 0x91, 0x2D, 0x72, 0x00, 0x64, 0x12, 0x08,
> +		0x43, 0x20, 0x0E, 0xD9, 0x45, 0xA0, 0x34, 0xC0,
> +		0x0B, 0x80, 0x12, 0x87, 0x08, 0x24, 0x24, 0x71,
> +		0x54, 0xE2, 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4212, .pixclk = 74176000, .data = {
> +		0x01, 0x91, 0x3E, 0x35, 0x00, 0x5B, 0xDE, 0x08,
> +		0x82, 0x20, 0x73, 0xD9, 0x45, 0xA0, 0x34, 0xC0,
> +		0x0B, 0x80, 0x12, 0x87, 0x08, 0x24, 0x24, 0x52,
> +		0x54, 0xA5, 0x24, 0x01, 0x00, 0x00, 0x01, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4212, .pixclk = 74250000, .data = {
> +		0x01, 0x91, 0x3E, 0x35, 0x00, 0x40, 0xF0, 0x08,
> +		0x82, 0x20, 0x73, 0xD9, 0x45, 0xA0, 0x34, 0xC0,
> +		0x0B, 0x80, 0x12, 0x87, 0x08, 0x24, 0x24, 0x52,
> +		0x54, 0xA4, 0x24, 0x01, 0x00, 0x00, 0x01, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4212, .pixclk = 148500000, .data = {
> +		0x01, 0x91, 0x3E, 0x15, 0x00, 0x40, 0xF0, 0x08,
> +		0x82, 0x20, 0x73, 0xD9, 0x45, 0xA0, 0x34, 0xC0,
> +		0x0B, 0x80, 0x12, 0x87, 0x08, 0x24, 0x24, 0xA4,
> +		0x54, 0x4A, 0x25, 0x03, 0x00, 0x00, 0x01, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4412, .pixclk = 27000000, .data = {
> +		0x01, 0x11, 0x2D, 0x75, 0x40, 0x01, 0x00, 0x08,
> +		0x82, 0x00, 0x0E, 0xD9, 0x45, 0xA0, 0xAC, 0x80,
> +		0x08, 0x80, 0x11, 0x84, 0x02, 0x22, 0x44, 0x86,
> +		0x54, 0xE4, 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4412, .pixclk = 27027000, .data = {
> +		0x01, 0x91, 0x2D, 0x72, 0x40, 0x64, 0x12, 0x08,
> +		0x43, 0x20, 0x0E, 0xD9, 0x45, 0xA0, 0xAC, 0x80,
> +		0x08, 0x80, 0x11, 0x84, 0x02, 0x22, 0x44, 0x86,
> +		0x54, 0xE3, 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4412, .pixclk = 74176000, .data = {
> +		0x01, 0x91, 0x1F, 0x10, 0x40, 0x5B, 0xEF, 0x08,
> +		0x81, 0x20, 0xB9, 0xD8, 0x45, 0xA0, 0xAC, 0x80,
> +		0x08, 0x80, 0x11, 0x84, 0x02, 0x22, 0x44, 0x86,
> +		0x54, 0xA6, 0x24, 0x01, 0x00, 0x00, 0x01, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4412, .pixclk = 74250000, .data = {
> +		0x01, 0x91, 0x1F, 0x10, 0x40, 0x40, 0xF8, 0x08,
> +		0x81, 0x20, 0xBA, 0xD8, 0x45, 0xA0, 0xAC, 0x80,
> +		0x08, 0x80, 0x11, 0x84, 0x02, 0x22, 0x44, 0x86,
> +		0x54, 0xA5, 0x24, 0x01, 0x00, 0x00, 0x01, 0x00, }
> +	},
> +	{ .id = HDMIPHY_EXYNOS4412, .pixclk = 148500000, .data = {
> +		0x01, 0x91, 0x1F, 0x00, 0x40, 0x40, 0xF8, 0x08,
> +		0x81, 0x20, 0xBA, 0xD8, 0x45, 0xA0, 0xAC, 0x80,
> +		0x08, 0x80, 0x11, 0x84, 0x02, 0x22, 0x44, 0x86,
> +		0x54, 0x4B, 0x25, 0x03, 0x00, 0x00, 0x01, 0x00, }
> +	},
>  };
> 
> -const u8 *hdmiphy_preset2conf(u32 preset)
> +static unsigned long hdmiphy_preset_to_pixclk(u32 preset)
>  {
> +	static const unsigned long pixclk[] = {
> +		[V4L2_DV_480P59_94] =  27000000,
> +		[V4L2_DV_576P50]    =  27000000,
> +		[V4L2_DV_720P59_94] =  74176000,
> +		[V4L2_DV_720P50]    =  74250000,
> +		[V4L2_DV_720P60]    =  74250000,
> +		[V4L2_DV_1080P24]   =  74250000,
> +		[V4L2_DV_1080P30]   =  74250000,
> +		[V4L2_DV_1080I50]   =  74250000,
> +		[V4L2_DV_1080I60]   =  74250000,
> +		[V4L2_DV_1080P50]   = 148500000,
> +		[V4L2_DV_1080P60]   = 148500000,
> +	};
> +	if (preset < ARRAY_SIZE(pixclk))
> +		return pixclk[preset];
> +	else
> +		return 0;
> +}
> +
> +static const u8 *hdmiphy_find_conf(u32 preset, enum hdmiphy_id id)
> +{
> +	unsigned long pixclk;
>  	int i;
> -	for (i = 0; i < ARRAY_SIZE(hdmiphy_conf); ++i)
> -		if (hdmiphy_conf[i].preset == preset)
> -			return hdmiphy_conf[i].data;
> +	const struct hdmiphy_conf *conf = hdmiphy_conf;
> +
> +	pixclk = hdmiphy_preset_to_pixclk(preset);
> +	if (!pixclk)
> +		return NULL;
> +
> +	for (i = 0; i < ARRAY_SIZE(hdmiphy_conf); ++i, ++conf)
> +		if (conf->pixclk == pixclk && conf->id == id)
> +			return conf->data;

It would be better to have one array per ID to avoid looping through entries 
that will never match. Given the size of the array that's not a major issue 
though.

>  	return NULL;
>  }
> 

-- 
Regards,

Laurent Pinchart


  reply	other threads:[~2012-03-14  1:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-13 13:35 [PATCH 0/6] Update to S5P-TV drivers Tomasz Stanislawski
2012-03-13 13:35 ` [PATCH 1/6] v4l: s5p-tv: mixer: fix compilation warning Tomasz Stanislawski
2012-03-13 13:35 ` [PATCH 2/6] v4l: s5p-tv: hdmiphy: add support for per-platform variants Tomasz Stanislawski
2012-03-14  1:13   ` Laurent Pinchart [this message]
2012-03-13 13:35 ` [PATCH 3/6] v4l: s5p-tv: hdmi: parametrize DV timings Tomasz Stanislawski
2012-03-13 13:35 ` [PATCH 4/6] v4l: s5p-tv: hdmi: fix mode synchronization Tomasz Stanislawski
2012-03-13 13:35 ` [PATCH 5/6] v4l: s5p-tv: mixer: fix handling of interlaced modes Tomasz Stanislawski
2012-03-13 13:35 ` [PATCH 6/6] s5p-tv: Fix section mismatch warning in mixer_video.c Tomasz Stanislawski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1720743.tF7fzoSFyt@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=hverkuil@xs4all.nl \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=sachin.kamat@linaro.org \
    --cc=t.stanislaws@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.