aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMats Randgaard <matrandg@cisco.com>2013-12-05 10:08:45 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-01-07 03:34:52 -0500
commit5b64b205392fcf3bbbc0cedddeb0aa33cd769801 (patch)
tree6222878f9cf8d52be0a6e5254c329e9281c130a2
parent7de6fab1fdc81381834db690ec0511ec87acc4d3 (diff)
[media] adv7842: mute audio before switching inputs to avoid noise/pops
Signed-off-by: Mats Randgaard <matrandg@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--drivers/media/i2c/adv7842.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index a26c70ca581c..bbd80acbabfe 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -20,10 +20,13 @@
20 20
21/* 21/*
22 * References (c = chapter, p = page): 22 * References (c = chapter, p = page):
23 * REF_01 - Analog devices, ADV7842, Register Settings Recommendations, 23 * REF_01 - Analog devices, ADV7842,
24 * Revision 2.5, June 2010 24 * Register Settings Recommendations, Rev. 1.9, April 2011
25 * REF_02 - Analog devices, Software User Guide, UG-206, 25 * REF_02 - Analog devices, Software User Guide, UG-206,
26 * ADV7842 I2C Register Maps, Rev. 0, November 2010 26 * ADV7842 I2C Register Maps, Rev. 0, November 2010
27 * REF_03 - Analog devices, Hardware User Guide, UG-214,
28 * ADV7842 Fast Switching 2:1 HDMI 1.4 Receiver with 3D-Comb
29 * Decoder and Digitizer , Rev. 0, January 2011
27 */ 30 */
28 31
29 32
@@ -491,6 +494,11 @@ static inline int hdmi_write(struct v4l2_subdev *sd, u8 reg, u8 val)
491 return adv_smbus_write_byte_data(state->i2c_hdmi, reg, val); 494 return adv_smbus_write_byte_data(state->i2c_hdmi, reg, val);
492} 495}
493 496
497static inline int hdmi_write_and_or(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 val)
498{
499 return hdmi_write(sd, reg, (hdmi_read(sd, reg) & mask) | val);
500}
501
494static inline int cp_read(struct v4l2_subdev *sd, u8 reg) 502static inline int cp_read(struct v4l2_subdev *sd, u8 reg)
495{ 503{
496 struct adv7842_state *state = to_state(sd); 504 struct adv7842_state *state = to_state(sd);
@@ -1459,14 +1467,12 @@ static void enable_input(struct v4l2_subdev *sd)
1459 case ADV7842_MODE_SDP: 1467 case ADV7842_MODE_SDP:
1460 case ADV7842_MODE_COMP: 1468 case ADV7842_MODE_COMP:
1461 case ADV7842_MODE_RGB: 1469 case ADV7842_MODE_RGB:
1462 /* enable */
1463 io_write(sd, 0x15, 0xb0); /* Disable Tristate of Pins (no audio) */ 1470 io_write(sd, 0x15, 0xb0); /* Disable Tristate of Pins (no audio) */
1464 break; 1471 break;
1465 case ADV7842_MODE_HDMI: 1472 case ADV7842_MODE_HDMI:
1466 /* enable */
1467 hdmi_write(sd, 0x1a, 0x0a); /* Unmute audio */
1468 hdmi_write(sd, 0x01, 0x00); /* Enable HDMI clock terminators */ 1473 hdmi_write(sd, 0x01, 0x00); /* Enable HDMI clock terminators */
1469 io_write(sd, 0x15, 0xa0); /* Disable Tristate of Pins */ 1474 io_write(sd, 0x15, 0xa0); /* Disable Tristate of Pins */
1475 hdmi_write_and_or(sd, 0x1a, 0xef, 0x00); /* Unmute audio */
1470 break; 1476 break;
1471 default: 1477 default:
1472 v4l2_dbg(2, debug, sd, "%s: Unknown mode %d\n", 1478 v4l2_dbg(2, debug, sd, "%s: Unknown mode %d\n",
@@ -1477,9 +1483,9 @@ static void enable_input(struct v4l2_subdev *sd)
1477 1483
1478static void disable_input(struct v4l2_subdev *sd) 1484static void disable_input(struct v4l2_subdev *sd)
1479{ 1485{
1480 /* disable */ 1486 hdmi_write_and_or(sd, 0x1a, 0xef, 0x10); /* Mute audio [REF_01, c. 2.2.2] */
1487 msleep(16); /* 512 samples with >= 32 kHz sample rate [REF_03, c. 8.29] */
1481 io_write(sd, 0x15, 0xbe); /* Tristate all outputs from video core */ 1488 io_write(sd, 0x15, 0xbe); /* Tristate all outputs from video core */
1482 hdmi_write(sd, 0x1a, 0x1a); /* Mute audio */
1483 hdmi_write(sd, 0x01, 0x78); /* Disable HDMI clock terminators */ 1489 hdmi_write(sd, 0x01, 0x78); /* Disable HDMI clock terminators */
1484} 1490}
1485 1491
@@ -2432,6 +2438,9 @@ static int adv7842_core_init(struct v4l2_subdev *sd)
2432 pdata->replicate_av_codes << 1 | 2438 pdata->replicate_av_codes << 1 |
2433 pdata->invert_cbcr << 0); 2439 pdata->invert_cbcr << 0);
2434 2440
2441 /* HDMI audio */
2442 hdmi_write_and_or(sd, 0x1a, 0xf1, 0x08); /* Wait 1 s before unmute */
2443
2435 /* Drive strength */ 2444 /* Drive strength */
2436 io_write_and_or(sd, 0x14, 0xc0, pdata->drive_strength.data<<4 | 2445 io_write_and_or(sd, 0x14, 0xc0, pdata->drive_strength.data<<4 |
2437 pdata->drive_strength.clock<<2 | 2446 pdata->drive_strength.clock<<2 |