From 6e2621bce7b549170fd47a8b758ad96038f9dd3d Mon Sep 17 00:00:00 2001 From: Susis Strolch Date: Mon, 11 Aug 2014 22:34:51 +0200 Subject: [PATCH] CuboxI: further improvements from warped-rudi --- ...dd-support-for-full-6-byte-channel-s.patch | 176 ++++++++++++++++++ ...a-Further-increase-audio-buffer-size.patch | 36 ++++ ...t_value_for_AES3_when_using_HBR_mode.patch | 29 +++ ...c-999.99-relax_sink_buffersize_check.patch | 11 ++ 4 files changed, 252 insertions(+) create mode 100644 projects/Cuboxi/patches/linux/linux-999.99.32-ASoC-fsl_spdif-Add-support-for-full-6-byte-channel-s.patch create mode 100644 projects/Cuboxi/patches/linux/linux-999.99.33-ASoC-imx-hdmi-dma-Further-increase-audio-buffer-size.patch create mode 100644 projects/Cuboxi/patches/xbmc/xbmc-999.99-AESinkALSA:_Set_correct_value_for_AES3_when_using_HBR_mode.patch create mode 100644 projects/Cuboxi/patches/xbmc/xbmc-999.99-relax_sink_buffersize_check.patch diff --git a/projects/Cuboxi/patches/linux/linux-999.99.32-ASoC-fsl_spdif-Add-support-for-full-6-byte-channel-s.patch b/projects/Cuboxi/patches/linux/linux-999.99.32-ASoC-fsl_spdif-Add-support-for-full-6-byte-channel-s.patch new file mode 100644 index 0000000000..7cb5afc019 --- /dev/null +++ b/projects/Cuboxi/patches/linux/linux-999.99.32-ASoC-fsl_spdif-Add-support-for-full-6-byte-channel-s.patch @@ -0,0 +1,176 @@ +From dd9ceaf071b535dbbacfbb90e4b909f66058413d Mon Sep 17 00:00:00 2001 +From: warped-rudi +Date: Mon, 11 Aug 2014 09:39:33 +0200 +Subject: [PATCH 1/1] ASoC: fsl_spdif: Add support for full 6 byte channel + status. + +This patch allows all 6 bytes ot the SPDIF channel status information +to be transmitted. +--- + sound/soc/fsl/fsl_spdif.c | 49 ++++++++++++++++++++++++++++------------------- + 1 file changed, 29 insertions(+), 20 deletions(-) + +diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c +index 1eaaa79..e102721 100644 +--- a/sound/soc/fsl/fsl_spdif.c ++++ b/sound/soc/fsl/fsl_spdif.c +@@ -55,7 +55,7 @@ struct spdif_mixer_control { + spinlock_t ctl_lock; + + /* IEC958 channel tx status bit */ +- unsigned char ch_status[4]; ++ unsigned char ch_status[6]; + + /* User bits */ + unsigned char subcode[2 * SPDIF_UBITS_SIZE]; +@@ -299,11 +299,11 @@ static int spdif_softreset(struct fsl_spdif_priv *spdif_priv) + return -EBUSY; + } + +-static void spdif_set_cstatus(struct spdif_mixer_control *ctrl, +- u8 mask, u8 cstatus) ++static inline void spdif_set_cstatus(struct spdif_mixer_control *ctrl, ++ u8 byteno, u8 mask, u8 cstatus) + { +- ctrl->ch_status[3] &= ~mask; +- ctrl->ch_status[3] |= cstatus & mask; ++ ctrl->ch_status[byteno] &= ~mask; ++ ctrl->ch_status[byteno] |= cstatus & mask; + } + + static void spdif_write_channel_status(struct fsl_spdif_priv *spdif_priv) +@@ -320,13 +320,15 @@ static void spdif_write_channel_status(struct fsl_spdif_priv *spdif_priv) + + dev_dbg(&pdev->dev, "STCSCH: 0x%06x\n", ch_status); + +- ch_status = bitrev8(ctrl->ch_status[3]) << 16; ++ ch_status = bitrev8(ctrl->ch_status[3]) << 16 | ++ (bitrev8(ctrl->ch_status[4]) << 8) | ++ bitrev8(ctrl->ch_status[5]); + regmap_write(regmap, REG_SPDIF_STCSCL, ch_status); + + dev_dbg(&pdev->dev, "STCSCL: 0x%06x\n", ch_status); + + /* Set outgoing validity (0: pcm, 1: non-audio) */ +- regmap_update_bits(regmap, REG_SPDIF_SCR, SCR_VAL_MASK, ++ regmap_update_bits(regmap, REG_SPDIF_SCR, SCR_VAL_MASK, + (ctrl->ch_status[0] & IEC958_AES0_NONAUDIO) ? 0 : SCR_VAL_CLEAR); + } + +@@ -355,39 +357,45 @@ static int spdif_set_sample_rate(struct snd_pcm_substream *substream, + struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; + struct regmap *regmap = spdif_priv->regmap; + struct platform_device *pdev = spdif_priv->pdev; +- unsigned long csfs = 0; + u32 stc, mask, rate; +- u8 clk, div; ++ u8 clk, div, csfs, csofs; + int ret; + + switch (sample_rate) { + case 32000: + rate = SPDIF_TXRATE_32000; + csfs = IEC958_AES3_CON_FS_32000; ++ csofs = IEC958_AES4_CON_ORIGFS_32000; + break; + case 44100: + rate = SPDIF_TXRATE_44100; + csfs = IEC958_AES3_CON_FS_44100; ++ csofs = IEC958_AES4_CON_ORIGFS_44100; + break; + case 48000: + rate = SPDIF_TXRATE_48000; + csfs = IEC958_AES3_CON_FS_48000; ++ csofs = IEC958_AES4_CON_ORIGFS_48000; + break; + case 88200: + rate = SPDIF_TXRATE_88200; + csfs = IEC958_AES3_CON_FS_88200; ++ csofs = IEC958_AES4_CON_ORIGFS_88200; + break; + case 96000: + rate = SPDIF_TXRATE_96000; + csfs = IEC958_AES3_CON_FS_96000; ++ csofs = IEC958_AES4_CON_ORIGFS_96000; + break; + case 176400: + rate = SPDIF_TXRATE_176400; + csfs = IEC958_AES3_CON_FS_176400; ++ csofs = IEC958_AES4_CON_ORIGFS_176400; + break; + case 192000: + rate = SPDIF_TXRATE_192000; + csfs = IEC958_AES3_CON_FS_192000; ++ csofs = IEC958_AES4_CON_ORIGFS_192000; + break; + default: + dev_err(&pdev->dev, "unsupported sample rate %d\n", sample_rate); +@@ -423,7 +431,8 @@ static int spdif_set_sample_rate(struct snd_pcm_substream *substream, + clk_get_rate(spdif_priv->txclk[rate])); + + /* set fs field in consumer channel status */ +- spdif_set_cstatus(ctrl, IEC958_AES3_CON_FS, csfs); ++ spdif_set_cstatus(ctrl, 3, IEC958_AES3_CON_FS, csfs); ++ spdif_set_cstatus(ctrl, 4, IEC958_AES4_CON_ORIGFS, csofs); + + /* select clock source and divisor */ + stc = STC_TXCLK_ALL_EN | STC_TXCLK_SRC_SET(clk) | STC_TXCLK_DIV(div); +@@ -535,8 +544,8 @@ static int fsl_spdif_hw_params(struct snd_pcm_substream *substream, + __func__, sample_rate); + return ret; + } +- spdif_set_cstatus(ctrl, IEC958_AES3_CON_CLOCK, +- IEC958_AES3_CON_CLOCK_1000PPM); ++ spdif_set_cstatus(ctrl, 3, IEC958_AES3_CON_CLOCK, ++ IEC958_AES3_CON_CLOCK_1000PPM); + spdif_write_channel_status(spdif_priv); + } else { + /* Setup rx clock source */ +@@ -606,14 +615,13 @@ static int fsl_spdif_info(struct snd_kcontrol *kcontrol, + static int fsl_spdif_pb_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *uvalue) + { ++ int i; + struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol); + struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); + struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; + +- uvalue->value.iec958.status[0] = ctrl->ch_status[0]; +- uvalue->value.iec958.status[1] = ctrl->ch_status[1]; +- uvalue->value.iec958.status[2] = ctrl->ch_status[2]; +- uvalue->value.iec958.status[3] = ctrl->ch_status[3]; ++ for (i = 0; i < ARRAY_SIZE(ctrl->ch_status); i++) ++ uvalue->value.iec958.status[i] = ctrl->ch_status[i]; + + return 0; + } +@@ -621,14 +629,13 @@ static int fsl_spdif_pb_get(struct snd_kcontrol *kcontrol, + static int fsl_spdif_pb_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *uvalue) + { ++ int i; + struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol); + struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); + struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; + +- ctrl->ch_status[0] = uvalue->value.iec958.status[0]; +- ctrl->ch_status[1] = uvalue->value.iec958.status[1]; +- ctrl->ch_status[2] = uvalue->value.iec958.status[2]; +- ctrl->ch_status[3] = uvalue->value.iec958.status[3]; ++ for (i = 0; i < ARRAY_SIZE(ctrl->ch_status); i++) ++ ctrl->ch_status[i] = uvalue->value.iec958.status[i]; + + spdif_write_channel_status(spdif_priv); + +@@ -1213,6 +1220,8 @@ static int fsl_spdif_probe(struct platform_device *pdev) + ctrl->ch_status[2] = 0x00; + ctrl->ch_status[3] = + IEC958_AES3_CON_FS_44100 | IEC958_AES3_CON_CLOCK_1000PPM; ++ ctrl->ch_status[4] = IEC958_AES4_CON_ORIGFS_44100; ++ ctrl->ch_status[5] = IEC958_AES5_CON_CGMSA_COPYFREELY; + + spdif_priv->dpll_locked = false; + +-- +1.9.1 + diff --git a/projects/Cuboxi/patches/linux/linux-999.99.33-ASoC-imx-hdmi-dma-Further-increase-audio-buffer-size.patch b/projects/Cuboxi/patches/linux/linux-999.99.33-ASoC-imx-hdmi-dma-Further-increase-audio-buffer-size.patch new file mode 100644 index 0000000000..eee5169fab --- /dev/null +++ b/projects/Cuboxi/patches/linux/linux-999.99.33-ASoC-imx-hdmi-dma-Further-increase-audio-buffer-size.patch @@ -0,0 +1,36 @@ +From a71939b0ffdc9746c55e95f25a152c705eee140b Mon Sep 17 00:00:00 2001 +From: Rudi +Date: Sun, 10 Aug 2014 21:15:49 +0200 +Subject: [PATCH 1/1] ASoC: imx-hdmi-dma: Further increase audio buffer size + +--- + sound/soc/fsl/imx-hdmi-dma.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/sound/soc/fsl/imx-hdmi-dma.c b/sound/soc/fsl/imx-hdmi-dma.c +index 53b6c9a..a6ebb16 100644 +--- a/sound/soc/fsl/imx-hdmi-dma.c ++++ b/sound/soc/fsl/imx-hdmi-dma.c +@@ -142,8 +142,8 @@ EXPORT_SYMBOL(iec_header); + * is necessary for 6 ch. + */ + #define HDMI_DMA_PERIOD_BYTES (6144) +-#define HDMI_DMA_BUF_SIZE (16 * 64 * 1024) +-#define HDMI_PCM_BUF_SIZE (16 * 64 * 1024) ++#define HDMI_DMA_BUF_SIZE (24 * 64 * 1024) ++#define HDMI_PCM_BUF_SIZE (24 * 64 * 1024) + + #define hdmi_audio_debug(dev, reg) \ + dev_dbg(dev, #reg ": 0x%02x\n", hdmi_readb(reg)) +@@ -1011,7 +1011,7 @@ static struct snd_pcm_hardware snd_imx_hardware = { + .period_bytes_min = HDMI_DMA_PERIOD_BYTES / 2, + .period_bytes_max = HDMI_DMA_PERIOD_BYTES / 2, + .periods_min = 8, +- .periods_max = 8*16, ++ .periods_max = HDMI_DMA_BUF_SIZE / HDMI_DMA_PERIOD_BYTES, + .fifo_size = 0, + }; + +-- +1.9.1 + diff --git a/projects/Cuboxi/patches/xbmc/xbmc-999.99-AESinkALSA:_Set_correct_value_for_AES3_when_using_HBR_mode.patch b/projects/Cuboxi/patches/xbmc/xbmc-999.99-AESinkALSA:_Set_correct_value_for_AES3_when_using_HBR_mode.patch new file mode 100644 index 0000000000..c6b71f2592 --- /dev/null +++ b/projects/Cuboxi/patches/xbmc/xbmc-999.99-AESinkALSA:_Set_correct_value_for_AES3_when_using_HBR_mode.patch @@ -0,0 +1,29 @@ +From 22477eaf1286dd28fb87552d35e9c8a5dbc09658 Mon Sep 17 00:00:00 2001 +From: Rudi +Date: Sat, 9 Aug 2014 18:09:03 +0200 +Subject: [PATCH] AESinkALSA: Set correct value for AES3 when using HBR mode + +According to the HDMI 1.4a document, the only acceptable value +for AES3 in HBR mode is 0x09, which corresponds to a frame rate +of 768000. Some sinks or drivers ignore this, but some do not. +--- + xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp +index c608231..322b8de 100644 +--- a/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp ++++ b/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp +@@ -156,7 +156,8 @@ void CAESinkALSA::GetAESParams(AEAudioFormat format, std::string& params) + + params += ",AES1=0x82,AES2=0x00"; + +- if (format.m_sampleRate == 192000) params += ",AES3=0x0e"; ++ if (m_passthrough && format.m_channelLayout.Count() == 8) params += ",AES3=0x09"; ++ else if (format.m_sampleRate == 192000) params += ",AES3=0x0e"; + else if (format.m_sampleRate == 176400) params += ",AES3=0x0c"; + else if (format.m_sampleRate == 96000) params += ",AES3=0x0a"; + else if (format.m_sampleRate == 88200) params += ",AES3=0x08"; +-- +2.0.3 + diff --git a/projects/Cuboxi/patches/xbmc/xbmc-999.99-relax_sink_buffersize_check.patch b/projects/Cuboxi/patches/xbmc/xbmc-999.99-relax_sink_buffersize_check.patch new file mode 100644 index 0000000000..0c036b07e4 --- /dev/null +++ b/projects/Cuboxi/patches/xbmc/xbmc-999.99-relax_sink_buffersize_check.patch @@ -0,0 +1,11 @@ +--- xbmc-master-14-dae6f76/./xbmc/cores/AudioEngine/AESinkFactory.cpp.orig 2014-07-07 18:30:37.000000000 +0200 ++++ xbmc-master-14-dae6f76/./xbmc/cores/AudioEngine/AESinkFactory.cpp 2014-07-15 10:30:16.513471771 +0200 +@@ -134,7 +134,7 @@ + CLog::Log(LOGERROR, "Sink %s:%s returned invalid sample rate", driver.c_str(), device.c_str()); + else if (format.m_channelLayout.Count() == 0) + CLog::Log(LOGERROR, "Sink %s:%s returned invalid channel layout", driver.c_str(), device.c_str()); +- else if (format.m_frames < 256) ++ else if (format.m_frames < 96) + CLog::Log(LOGERROR, "Sink %s:%s returned invalid buffer size: %d", driver.c_str(), device.c_str(), format.m_frames); + else + return sink;