aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-03-04 07:28:57 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-23 09:58:05 -0400
commit8cf2f7ad9749980a455d61b5664ccb553c12fd0e (patch)
tree5ac217917301fbbf20a7edfff61f949b60debe8c
parent8b2c3da108b08751ac65911e1797ef9a5342c727 (diff)
[media] s5p-tv: add dv_timings support for hdmiphy
This just adds dv_timings support without modifying existing dv_preset support, although I had to refactor a little bit in order to share hdmiphy_find_conf() between the preset and timings code. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Tested-by: Tomasz Stanislawski <t.stanislaws@samsung.com> Acked-by: Tomasz Stanislawski <t.stanislaws@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/platform/s5p-tv/hdmiphy_drv.c60
1 files changed, 51 insertions, 9 deletions
diff --git a/drivers/media/platform/s5p-tv/hdmiphy_drv.c b/drivers/media/platform/s5p-tv/hdmiphy_drv.c
index 80717cec76ae..ef0d8122f3e9 100644
--- a/drivers/media/platform/s5p-tv/hdmiphy_drv.c
+++ b/drivers/media/platform/s5p-tv/hdmiphy_drv.c
@@ -197,14 +197,9 @@ static unsigned long hdmiphy_preset_to_pixclk(u32 preset)
197 return 0; 197 return 0;
198} 198}
199 199
200static const u8 *hdmiphy_find_conf(u32 preset, const struct hdmiphy_conf *conf) 200static const u8 *hdmiphy_find_conf(unsigned long pixclk,
201 const struct hdmiphy_conf *conf)
201{ 202{
202 unsigned long pixclk;
203
204 pixclk = hdmiphy_preset_to_pixclk(preset);
205 if (!pixclk)
206 return NULL;
207
208 for (; conf->pixclk; ++conf) 203 for (; conf->pixclk; ++conf)
209 if (conf->pixclk == pixclk) 204 if (conf->pixclk == pixclk)
210 return conf->data; 205 return conf->data;
@@ -220,15 +215,49 @@ static int hdmiphy_s_power(struct v4l2_subdev *sd, int on)
220static int hdmiphy_s_dv_preset(struct v4l2_subdev *sd, 215static int hdmiphy_s_dv_preset(struct v4l2_subdev *sd,
221 struct v4l2_dv_preset *preset) 216 struct v4l2_dv_preset *preset)
222{ 217{
223 const u8 *data; 218 const u8 *data = NULL;
224 u8 buffer[32]; 219 u8 buffer[32];
225 int ret; 220 int ret;
226 struct hdmiphy_ctx *ctx = sd_to_ctx(sd); 221 struct hdmiphy_ctx *ctx = sd_to_ctx(sd);
227 struct i2c_client *client = v4l2_get_subdevdata(sd); 222 struct i2c_client *client = v4l2_get_subdevdata(sd);
223 unsigned long pixclk;
228 struct device *dev = &client->dev; 224 struct device *dev = &client->dev;
229 225
230 dev_info(dev, "s_dv_preset(preset = %d)\n", preset->preset); 226 dev_info(dev, "s_dv_preset(preset = %d)\n", preset->preset);
231 data = hdmiphy_find_conf(preset->preset, ctx->conf_tab); 227
228 pixclk = hdmiphy_preset_to_pixclk(preset->preset);
229 data = hdmiphy_find_conf(pixclk, ctx->conf_tab);
230 if (!data) {
231 dev_err(dev, "format not supported\n");
232 return -EINVAL;
233 }
234
235 /* storing configuration to the device */
236 memcpy(buffer, data, 32);
237 ret = i2c_master_send(client, buffer, 32);
238 if (ret != 32) {
239 dev_err(dev, "failed to configure HDMIPHY via I2C\n");
240 return -EIO;
241 }
242
243 return 0;
244}
245
246static int hdmiphy_s_dv_timings(struct v4l2_subdev *sd,
247 struct v4l2_dv_timings *timings)
248{
249 const u8 *data;
250 u8 buffer[32];
251 int ret;
252 struct hdmiphy_ctx *ctx = sd_to_ctx(sd);
253 struct i2c_client *client = v4l2_get_subdevdata(sd);
254 struct device *dev = &client->dev;
255 unsigned long pixclk = timings->bt.pixelclock;
256
257 dev_info(dev, "s_dv_timings\n");
258 if ((timings->bt.flags & V4L2_DV_FL_REDUCED_FPS) && pixclk == 74250000)
259 pixclk = 74176000;
260 data = hdmiphy_find_conf(pixclk, ctx->conf_tab);
232 if (!data) { 261 if (!data) {
233 dev_err(dev, "format not supported\n"); 262 dev_err(dev, "format not supported\n");
234 return -EINVAL; 263 return -EINVAL;
@@ -245,6 +274,17 @@ static int hdmiphy_s_dv_preset(struct v4l2_subdev *sd,
245 return 0; 274 return 0;
246} 275}
247 276
277static int hdmiphy_dv_timings_cap(struct v4l2_subdev *sd,
278 struct v4l2_dv_timings_cap *cap)
279{
280 cap->type = V4L2_DV_BT_656_1120;
281 /* The phy only determines the pixelclock, leave the other values
282 * at 0 to signify that we have no information for them. */
283 cap->bt.min_pixelclock = 27000000;
284 cap->bt.max_pixelclock = 148500000;
285 return 0;
286}
287
248static int hdmiphy_s_stream(struct v4l2_subdev *sd, int enable) 288static int hdmiphy_s_stream(struct v4l2_subdev *sd, int enable)
249{ 289{
250 struct i2c_client *client = v4l2_get_subdevdata(sd); 290 struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -271,6 +311,8 @@ static const struct v4l2_subdev_core_ops hdmiphy_core_ops = {
271 311
272static const struct v4l2_subdev_video_ops hdmiphy_video_ops = { 312static const struct v4l2_subdev_video_ops hdmiphy_video_ops = {
273 .s_dv_preset = hdmiphy_s_dv_preset, 313 .s_dv_preset = hdmiphy_s_dv_preset,
314 .s_dv_timings = hdmiphy_s_dv_timings,
315 .dv_timings_cap = hdmiphy_dv_timings_cap,
274 .s_stream = hdmiphy_s_stream, 316 .s_stream = hdmiphy_s_stream,
275}; 317};
276 318