Skip to content

Commit

Permalink
tc358840: Audio Capture Stereo on HDMI-In-B to I2S1 via separate cable
Browse files Browse the repository at this point in the history
Note: it is necessary to export&unexport some GPIOs after boot:
echo 8 > /sys/class/gpio/export #LRC
echo 9 > /sys/class/gpio/export #Data in
echo 11 > /sys/class/gpio/export #SCLK
echo 8 > /sys/class/gpio/unexport
echo 9 > /sys/class/gpio/unexport
echo 11 > /sys/class/gpio/unexport
  • Loading branch information
Tobias Kammacher committed Nov 15, 2016
1 parent 244069e commit 9150157
Show file tree
Hide file tree
Showing 2 changed files with 177 additions and 0 deletions.
140 changes: 140 additions & 0 deletions arch/arm64/boot/dts/tegra210-jetson-tx1-p2597-2180-a01-devkit.dts
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,144 @@
regulator-always-on;
};
};

tegra_axbar: ahub {
status = "okay";

tegra_i2s4: i2s@702d1300 {
status = "okay";
};
};

sound_card: sound {
compatible = "nvidia,tegra-audio-t210ref-mobile-rt565x";
nvidia,model = "tegra-snd-t210ref-mobile-rt565x";

nvidia,num-codec-link = <5>;

nvidia,audio-routing =
"x Headphone Jack", "x HPO L Playback",
"x Headphone Jack", "x HPO R Playback",
"x MICBIAS1", "x Mic Jack",
"x IN1P", "x Mic Jack",
"x Mic Det Power", "x Mic Jack",
"x Int Spk", "x SPO Playback",
"x DMIC L1", "x Int Mic",
"x DMIC L2", "x Int Mic",
"x DMIC R1", "x Int Mic",
"x DMIC R2", "x Int Mic",
"x Headphone", "x OUT",
"x IN", "x Mic",
"y Headphone", "y OUT",
"y IN", "y Mic",
"l IN", "l OUT",
"s Headphone", "s OUT",
"s IN", "s Mic";

nvidia,xbar = <&tegra_axbar>;

/* The codec-dai here is initialized to dummy and will be */
/* replaced with rt565x codec-dai on detecting super-module */
nvidia,dai-link-1 {
link-name = "rt565x-playback";
cpu-dai = <&tegra_i2s1>;
codec-dai = <&spdif_dit4>;
cpu-dai-name = "I2S1";
codec-dai-name = "dit-hifi";
format = "i2s";
// bitclock-slave;
bitclock-master;
// frame-slave;
frame-master;
bitclock-noninversion;
frame-noninversion;
// bit-format = "s16_le";
bit-format = "s32_le";
// bclk_ratio = <0>;
bclk_ratio = <0>;
srate = <48000>;
num-channel = <2>;
ignore_suspend;
name-prefix = "x";
};

nvidia,dai-link-2 {
link-name = "spdif-dit-1";
cpu-dai = <&tegra_i2s2>;
codec-dai = <&spdif_dit1>;
cpu-dai-name = "I2S2";
codec-dai-name = "dit-hifi";
format = "dsp_a";
bitclock-slave;
frame-slave;
bitclock-inversion;
frame-inversion;
bit-format = "s16_le";
bclk_ratio = <4>;
srate = <8000>;
num-channel = <1>;
ignore_suspend;
name-prefix = "y";
};

nvidia,dai-link-3 {
link-name = "spdif-dit-2";
cpu-dai = <&tegra_dmic3>;
codec-dai = <&spdif_dit2>;
cpu-dai-name = "DMIC3";
codec-dai-name = "dit-hifi";
format = "i2s";
bit-format = "s16_le";
srate = <48000>;
num-channel = <2>;
ignore_suspend;
name-prefix = "z";
};

nvidia,dai-link-4 {
link-name = "spdif-dit-3";
cpu-dai = <&tegra_i2s3>;
codec-dai = <&spdif_dit3>;
cpu-dai-name = "I2S3";
codec-dai-name = "dit-hifi";
format = "i2s";
bitclock-slave;
frame-slave;
bitclock-noninversion;
frame-noninversion;
bit-format = "s16_le";
bclk_ratio = <0>;
srate = <48000>;
num-channel = <2>;
ignore_suspend;
name-prefix = "l";
};

nvidia,dai-link-5 {
link-name = "spdif-dit-0";
cpu-dai = <&tegra_i2s4>;
codec-dai = <&spdif_dit0>;
cpu-dai-name = "I2S4";
codec-dai-name = "dit-hifi";
format = "i2s";
// bitclock-slave;
bitclock-master;
// frame-slave;
frame-master;
bitclock-noninversion;
frame-noninversion;
// bit-format = "s16_le";
bit-format = "s32_le";
// bclk_ratio = <0>;
bclk_ratio = <0>;
srate = <48000>;
num-channel = <2>;
ignore_suspend;
name-prefix = "s";
};
};

hda@70030000 {
status = "okay";
};
};
37 changes: 37 additions & 0 deletions drivers/media/i2c/tc358840.c
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,42 @@ static void tc358840_set_hdmi_phy(struct v4l2_subdev *sd)

static void tc358840_set_hdmi_audio(struct v4l2_subdev *sd)
{
/* TDM */
#if 0
v4l2_dbg(3, debug, sd, "%s():\n", __func__);
/*
i2c_wr8(sd, FORCE_MUTE, 0x00);
i2c_wr8(sd, AUTO_CMD0, MASK_AUTO_MUTE7 | MASK_AUTO_MUTE6 |
MASK_AUTO_MUTE5 | MASK_AUTO_MUTE4 |
MASK_AUTO_MUTE1 | MASK_AUTO_MUTE0);
i2c_wr8(sd, AUTO_CMD1, MASK_AUTO_MUTE9);
i2c_wr8(sd, AUTO_CMD2, MASK_AUTO_PLAY3 | MASK_AUTO_PLAY2);
i2c_wr8(sd, BUFINIT_START, SET_BUFINIT_START_MS(500));
i2c_wr8(sd, FS_MUTE, 0x00);
i2c_wr8(sd, FS_IMODE, MASK_NLPCM_SMODE | MASK_FS_SMODE);
i2c_wr8(sd, ACR_MODE, MASK_CTS_MODE);
i2c_wr8(sd, ACR_MDF0, MASK_ACR_L2MDF_1976_PPM | MASK_ACR_L1MDF_976_PPM);
i2c_wr8(sd, ACR_MDF1, MASK_ACR_L3MDF_3906_PPM);*/
/*
* TODO: Set output data bit length (currently 16 bit, 8 bit discarded)
*/
/*i2c_wr8(sd, SDO_MODE1, MASK_SDO_FMT_I2S);
i2c_wr8(sd, DIV_MODE, SET_DIV_DLY_MS(100));
i2c_wr16_and_or(sd, CONFCTL0, 0xFFFF, MASK_AUDCHNUM_2 |
MASK_AUDOUTSEL_I2S | MASK_AUTOINDEX);*/

i2c_wr8(sd, FORCE_MUTE, 0x00);
i2c_wr8(sd, AUTO_CMD0, 0xF3);
i2c_wr8(sd, AUTO_CMD1, 0x02);
i2c_wr8(sd, AUTO_CMD2, 0x0C);
i2c_wr8(sd, BUFINIT_START, SET_BUFINIT_START_MS(500));
i2c_wr8(sd, FS_MUTE, 0x00);
i2c_wr8(sd, FS_SET, MASK_FS); /*new*/
i2c_wr8(sd, SDO_MODE1, 0x62);
i2c_wr8(sd, HDMIAUDIO_MODE, 0x00);
i2c_wr16_and_or(sd, CONFCTL0, ~(MASK_AUDCHNUM | MASK_AUDOUTSEL), MASK_AUDOUTSEL_TDM);
#else
/* I2S */
v4l2_dbg(3, debug, sd, "%s():\n", __func__);

i2c_wr8(sd, FORCE_MUTE, 0x00);
Expand All @@ -1194,6 +1230,7 @@ static void tc358840_set_hdmi_audio(struct v4l2_subdev *sd)
i2c_wr8(sd, DIV_MODE, SET_DIV_DLY_MS(100));
i2c_wr16_and_or(sd, CONFCTL0, 0xFFFF, MASK_AUDCHNUM_2 |
MASK_AUDOUTSEL_I2S | MASK_AUTOINDEX);
#endif
}

static void tc358840_set_hdmi_info_frame_mode(struct v4l2_subdev *sd)
Expand Down

0 comments on commit 9150157

Please sign in to comment.