aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLad, Prabhakar <prabhakar.lad@ti.com>2013-01-21 23:19:50 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-02-05 15:45:47 -0500
commit0b302d88534f0811c5f49bfba7aa46c4e1e032b7 (patch)
tree9a8a527e537d5bc5f60754e5bb4246c2e0990ab9
parented57256f6fe8882cf6dde8d99f5fac5fd84c5a2d (diff)
[media] media: adv7343: accept configuration through platform data
The current code was implemented with some default configurations, this default configuration works on board and doesn't work on other. This patch accepts the configuration through platform data and configures the encoder depending on the data passed. Signed-off-by: Lad, Prabhakar <prabhakar.lad@ti.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/i2c/adv7343.c36
-rw-r--r--include/media/adv7343.h52
2 files changed, 83 insertions, 5 deletions
diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c
index 432eb5f7a0e5..9fc2b985df0e 100644
--- a/drivers/media/i2c/adv7343.c
+++ b/drivers/media/i2c/adv7343.c
@@ -43,6 +43,7 @@ MODULE_PARM_DESC(debug, "Debug level 0-1");
43struct adv7343_state { 43struct adv7343_state {
44 struct v4l2_subdev sd; 44 struct v4l2_subdev sd;
45 struct v4l2_ctrl_handler hdl; 45 struct v4l2_ctrl_handler hdl;
46 const struct adv7343_platform_data *pdata;
46 u8 reg00; 47 u8 reg00;
47 u8 reg01; 48 u8 reg01;
48 u8 reg02; 49 u8 reg02;
@@ -215,12 +216,23 @@ static int adv7343_setoutput(struct v4l2_subdev *sd, u32 output_type)
215 /* Enable Appropriate DAC */ 216 /* Enable Appropriate DAC */
216 val = state->reg00 & 0x03; 217 val = state->reg00 & 0x03;
217 218
218 if (output_type == ADV7343_COMPOSITE_ID) 219 /* configure default configuration */
219 val |= ADV7343_COMPOSITE_POWER_VALUE; 220 if (!state->pdata)
220 else if (output_type == ADV7343_COMPONENT_ID) 221 if (output_type == ADV7343_COMPOSITE_ID)
221 val |= ADV7343_COMPONENT_POWER_VALUE; 222 val |= ADV7343_COMPOSITE_POWER_VALUE;
223 else if (output_type == ADV7343_COMPONENT_ID)
224 val |= ADV7343_COMPONENT_POWER_VALUE;
225 else
226 val |= ADV7343_SVIDEO_POWER_VALUE;
222 else 227 else
223 val |= ADV7343_SVIDEO_POWER_VALUE; 228 val = state->pdata->mode_config.sleep_mode << 0 |
229 state->pdata->mode_config.pll_control << 1 |
230 state->pdata->mode_config.dac_3 << 2 |
231 state->pdata->mode_config.dac_2 << 3 |
232 state->pdata->mode_config.dac_1 << 4 |
233 state->pdata->mode_config.dac_6 << 5 |
234 state->pdata->mode_config.dac_5 << 6 |
235 state->pdata->mode_config.dac_4 << 7;
224 236
225 err = adv7343_write(sd, ADV7343_POWER_MODE_REG, val); 237 err = adv7343_write(sd, ADV7343_POWER_MODE_REG, val);
226 if (err < 0) 238 if (err < 0)
@@ -238,6 +250,17 @@ static int adv7343_setoutput(struct v4l2_subdev *sd, u32 output_type)
238 250
239 /* configure SD DAC Output 2 and SD DAC Output 1 bit to zero */ 251 /* configure SD DAC Output 2 and SD DAC Output 1 bit to zero */
240 val = state->reg82 & (SD_DAC_1_DI & SD_DAC_2_DI); 252 val = state->reg82 & (SD_DAC_1_DI & SD_DAC_2_DI);
253
254 if (state->pdata && state->pdata->sd_config.sd_dac_out1)
255 val = val | (state->pdata->sd_config.sd_dac_out1 << 1);
256 else if (state->pdata && !state->pdata->sd_config.sd_dac_out1)
257 val = val & ~(state->pdata->sd_config.sd_dac_out1 << 1);
258
259 if (state->pdata && state->pdata->sd_config.sd_dac_out2)
260 val = val | (state->pdata->sd_config.sd_dac_out2 << 2);
261 else if (state->pdata && !state->pdata->sd_config.sd_dac_out2)
262 val = val & ~(state->pdata->sd_config.sd_dac_out2 << 2);
263
241 err = adv7343_write(sd, ADV7343_SD_MODE_REG2, val); 264 err = adv7343_write(sd, ADV7343_SD_MODE_REG2, val);
242 if (err < 0) 265 if (err < 0)
243 goto setoutput_exit; 266 goto setoutput_exit;
@@ -402,6 +425,9 @@ static int adv7343_probe(struct i2c_client *client,
402 if (state == NULL) 425 if (state == NULL)
403 return -ENOMEM; 426 return -ENOMEM;
404 427
428 /* Copy board specific information here */
429 state->pdata = client->dev.platform_data;
430
405 state->reg00 = 0x80; 431 state->reg00 = 0x80;
406 state->reg01 = 0x00; 432 state->reg01 = 0x00;
407 state->reg02 = 0x20; 433 state->reg02 = 0x20;
diff --git a/include/media/adv7343.h b/include/media/adv7343.h
index d6f8a4e1a1fc..944757be49bb 100644
--- a/include/media/adv7343.h
+++ b/include/media/adv7343.h
@@ -20,4 +20,56 @@
20#define ADV7343_COMPONENT_ID (1) 20#define ADV7343_COMPONENT_ID (1)
21#define ADV7343_SVIDEO_ID (2) 21#define ADV7343_SVIDEO_ID (2)
22 22
23/**
24 * adv7343_power_mode - power mode configuration.
25 * @sleep_mode: on enable the current consumption is reduced to micro ampere
26 * level. All DACs and the internal PLL circuit are disabled.
27 * Registers can be read from and written in sleep mode.
28 * @pll_control: PLL and oversampling control. This control allows internal
29 * PLL 1 circuit to be powered down and the oversampling to be
30 * switched off.
31 * @dac_1: power on/off DAC 1.
32 * @dac_2: power on/off DAC 2.
33 * @dac_3: power on/off DAC 3.
34 * @dac_4: power on/off DAC 4.
35 * @dac_5: power on/off DAC 5.
36 * @dac_6: power on/off DAC 6.
37 *
38 * Power mode register (Register 0x0), for more info refer REGISTER MAP ACCESS
39 * section of datasheet[1], table 17 page no 30.
40 *
41 * [1] http://www.analog.com/static/imported-files/data_sheets/ADV7342_7343.pdf
42 */
43struct adv7343_power_mode {
44 bool sleep_mode;
45 bool pll_control;
46 bool dac_1;
47 bool dac_2;
48 bool dac_3;
49 bool dac_4;
50 bool dac_5;
51 bool dac_6;
52};
53
54/**
55 * struct adv7343_sd_config - SD Only Output Configuration.
56 * @sd_dac_out1: Configure SD DAC Output 1.
57 * @sd_dac_out2: Configure SD DAC Output 2.
58 */
59struct adv7343_sd_config {
60 /* SD only Output Configuration */
61 bool sd_dac_out1;
62 bool sd_dac_out2;
63};
64
65/**
66 * struct adv7343_platform_data - Platform data values and access functions.
67 * @mode_config: Configuration for power mode.
68 * @sd_config: SD Only Configuration.
69 */
70struct adv7343_platform_data {
71 struct adv7343_power_mode mode_config;
72 struct adv7343_sd_config sd_config;
73};
74
23#endif /* End of #ifndef ADV7343_H */ 75#endif /* End of #ifndef ADV7343_H */