aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/omap2/dss/hdmi.c236
-rw-r--r--drivers/video/omap2/dss/ti_hdmi_4xxx_ip.h5
2 files changed, 0 insertions, 241 deletions
diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
index 8f0549a2e796..0f8efc961e6b 100644
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -33,12 +33,6 @@
33#include <linux/pm_runtime.h> 33#include <linux/pm_runtime.h>
34#include <linux/clk.h> 34#include <linux/clk.h>
35#include <video/omapdss.h> 35#include <video/omapdss.h>
36#if defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI) || \
37 defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI_MODULE)
38#include <sound/soc.h>
39#include <sound/pcm_params.h>
40#include "ti_hdmi_4xxx_ip.h"
41#endif
42 36
43#include "ti_hdmi.h" 37#include "ti_hdmi.h"
44#include "dss.h" 38#include "dss.h"
@@ -539,220 +533,6 @@ void omapdss_hdmi_display_disable(struct omap_dss_device *dssdev)
539 mutex_unlock(&hdmi.lock); 533 mutex_unlock(&hdmi.lock);
540} 534}
541 535
542#if defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI) || \
543 defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI_MODULE)
544
545static int hdmi_audio_trigger(struct snd_pcm_substream *substream, int cmd,
546 struct snd_soc_dai *dai)
547{
548 struct snd_soc_pcm_runtime *rtd = substream->private_data;
549 struct snd_soc_codec *codec = rtd->codec;
550 struct platform_device *pdev = to_platform_device(codec->dev);
551 struct hdmi_ip_data *ip_data = snd_soc_codec_get_drvdata(codec);
552 int err = 0;
553
554 if (!(ip_data->ops) && !(ip_data->ops->audio_enable)) {
555 dev_err(&pdev->dev, "Cannot enable/disable audio\n");
556 return -ENODEV;
557 }
558
559 switch (cmd) {
560 case SNDRV_PCM_TRIGGER_START:
561 case SNDRV_PCM_TRIGGER_RESUME:
562 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
563 ip_data->ops->audio_enable(ip_data);
564 break;
565 case SNDRV_PCM_TRIGGER_STOP:
566 case SNDRV_PCM_TRIGGER_SUSPEND:
567 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
568 ip_data->ops->audio_disable(ip_data);
569 break;
570 default:
571 err = -EINVAL;
572 }
573 return err;
574}
575
576static int hdmi_audio_hw_params(struct snd_pcm_substream *substream,
577 struct snd_pcm_hw_params *params,
578 struct snd_soc_dai *dai)
579{
580 struct snd_soc_pcm_runtime *rtd = substream->private_data;
581 struct snd_soc_codec *codec = rtd->codec;
582 struct hdmi_ip_data *ip_data = snd_soc_codec_get_drvdata(codec);
583 struct hdmi_audio_format audio_format;
584 struct hdmi_audio_dma audio_dma;
585 struct hdmi_core_audio_config core_cfg;
586 struct hdmi_core_infoframe_audio aud_if_cfg;
587 int err, n, cts;
588 enum hdmi_core_audio_sample_freq sample_freq;
589
590 switch (params_format(params)) {
591 case SNDRV_PCM_FORMAT_S16_LE:
592 core_cfg.i2s_cfg.word_max_length =
593 HDMI_AUDIO_I2S_MAX_WORD_20BITS;
594 core_cfg.i2s_cfg.word_length = HDMI_AUDIO_I2S_CHST_WORD_16_BITS;
595 core_cfg.i2s_cfg.in_length_bits =
596 HDMI_AUDIO_I2S_INPUT_LENGTH_16;
597 core_cfg.i2s_cfg.justification = HDMI_AUDIO_JUSTIFY_LEFT;
598 audio_format.samples_per_word = HDMI_AUDIO_ONEWORD_TWOSAMPLES;
599 audio_format.sample_size = HDMI_AUDIO_SAMPLE_16BITS;
600 audio_format.justification = HDMI_AUDIO_JUSTIFY_LEFT;
601 audio_dma.transfer_size = 0x10;
602 break;
603 case SNDRV_PCM_FORMAT_S24_LE:
604 core_cfg.i2s_cfg.word_max_length =
605 HDMI_AUDIO_I2S_MAX_WORD_24BITS;
606 core_cfg.i2s_cfg.word_length = HDMI_AUDIO_I2S_CHST_WORD_24_BITS;
607 core_cfg.i2s_cfg.in_length_bits =
608 HDMI_AUDIO_I2S_INPUT_LENGTH_24;
609 audio_format.samples_per_word = HDMI_AUDIO_ONEWORD_ONESAMPLE;
610 audio_format.sample_size = HDMI_AUDIO_SAMPLE_24BITS;
611 audio_format.justification = HDMI_AUDIO_JUSTIFY_RIGHT;
612 core_cfg.i2s_cfg.justification = HDMI_AUDIO_JUSTIFY_RIGHT;
613 audio_dma.transfer_size = 0x20;
614 break;
615 default:
616 return -EINVAL;
617 }
618
619 switch (params_rate(params)) {
620 case 32000:
621 sample_freq = HDMI_AUDIO_FS_32000;
622 break;
623 case 44100:
624 sample_freq = HDMI_AUDIO_FS_44100;
625 break;
626 case 48000:
627 sample_freq = HDMI_AUDIO_FS_48000;
628 break;
629 default:
630 return -EINVAL;
631 }
632
633 err = hdmi_config_audio_acr(ip_data, params_rate(params), &n, &cts);
634 if (err < 0)
635 return err;
636
637 /* Audio wrapper config */
638 audio_format.stereo_channels = HDMI_AUDIO_STEREO_ONECHANNEL;
639 audio_format.active_chnnls_msk = 0x03;
640 audio_format.type = HDMI_AUDIO_TYPE_LPCM;
641 audio_format.sample_order = HDMI_AUDIO_SAMPLE_LEFT_FIRST;
642 /* Disable start/stop signals of IEC 60958 blocks */
643 audio_format.en_sig_blk_strt_end = HDMI_AUDIO_BLOCK_SIG_STARTEND_OFF;
644
645 audio_dma.block_size = 0xC0;
646 audio_dma.mode = HDMI_AUDIO_TRANSF_DMA;
647 audio_dma.fifo_threshold = 0x20; /* in number of samples */
648
649 hdmi_wp_audio_config_dma(ip_data, &audio_dma);
650 hdmi_wp_audio_config_format(ip_data, &audio_format);
651
652 /*
653 * I2S config
654 */
655 core_cfg.i2s_cfg.en_high_bitrate_aud = false;
656 /* Only used with high bitrate audio */
657 core_cfg.i2s_cfg.cbit_order = false;
658 /* Serial data and word select should change on sck rising edge */
659 core_cfg.i2s_cfg.sck_edge_mode = HDMI_AUDIO_I2S_SCK_EDGE_RISING;
660 core_cfg.i2s_cfg.vbit = HDMI_AUDIO_I2S_VBIT_FOR_PCM;
661 /* Set I2S word select polarity */
662 core_cfg.i2s_cfg.ws_polarity = HDMI_AUDIO_I2S_WS_POLARITY_LOW_IS_LEFT;
663 core_cfg.i2s_cfg.direction = HDMI_AUDIO_I2S_MSB_SHIFTED_FIRST;
664 /* Set serial data to word select shift. See Phillips spec. */
665 core_cfg.i2s_cfg.shift = HDMI_AUDIO_I2S_FIRST_BIT_SHIFT;
666 /* Enable one of the four available serial data channels */
667 core_cfg.i2s_cfg.active_sds = HDMI_AUDIO_I2S_SD0_EN;
668
669 /* Core audio config */
670 core_cfg.freq_sample = sample_freq;
671 core_cfg.n = n;
672 core_cfg.cts = cts;
673 if (dss_has_feature(FEAT_HDMI_CTS_SWMODE)) {
674 core_cfg.aud_par_busclk = 0;
675 core_cfg.cts_mode = HDMI_AUDIO_CTS_MODE_SW;
676 core_cfg.use_mclk = dss_has_feature(FEAT_HDMI_AUDIO_USE_MCLK);
677 } else {
678 core_cfg.aud_par_busclk = (((128 * 31) - 1) << 8);
679 core_cfg.cts_mode = HDMI_AUDIO_CTS_MODE_HW;
680 core_cfg.use_mclk = true;
681 }
682
683 if (core_cfg.use_mclk)
684 core_cfg.mclk_mode = HDMI_AUDIO_MCLK_128FS;
685 core_cfg.layout = HDMI_AUDIO_LAYOUT_2CH;
686 core_cfg.en_spdif = false;
687 /* Use sample frequency from channel status word */
688 core_cfg.fs_override = true;
689 /* Enable ACR packets */
690 core_cfg.en_acr_pkt = true;
691 /* Disable direct streaming digital audio */
692 core_cfg.en_dsd_audio = false;
693 /* Use parallel audio interface */
694 core_cfg.en_parallel_aud_input = true;
695
696 hdmi_core_audio_config(ip_data, &core_cfg);
697
698 /*
699 * Configure packet
700 * info frame audio see doc CEA861-D page 74
701 */
702 aud_if_cfg.db1_coding_type = HDMI_INFOFRAME_AUDIO_DB1CT_FROM_STREAM;
703 aud_if_cfg.db1_channel_count = 2;
704 aud_if_cfg.db2_sample_freq = HDMI_INFOFRAME_AUDIO_DB2SF_FROM_STREAM;
705 aud_if_cfg.db2_sample_size = HDMI_INFOFRAME_AUDIO_DB2SS_FROM_STREAM;
706 aud_if_cfg.db4_channel_alloc = 0x00;
707 aud_if_cfg.db5_downmix_inh = false;
708 aud_if_cfg.db5_lsv = 0;
709
710 hdmi_core_audio_infoframe_config(ip_data, &aud_if_cfg);
711 return 0;
712}
713
714static int hdmi_audio_startup(struct snd_pcm_substream *substream,
715 struct snd_soc_dai *dai)
716{
717 if (!hdmi.ip_data.cfg.cm.mode) {
718 pr_err("Current video settings do not support audio.\n");
719 return -EIO;
720 }
721 return 0;
722}
723
724static int hdmi_audio_codec_probe(struct snd_soc_codec *codec)
725{
726 struct hdmi_ip_data *priv = &hdmi.ip_data;
727
728 snd_soc_codec_set_drvdata(codec, priv);
729 return 0;
730}
731
732static struct snd_soc_codec_driver hdmi_audio_codec_drv = {
733 .probe = hdmi_audio_codec_probe,
734};
735
736static struct snd_soc_dai_ops hdmi_audio_codec_ops = {
737 .hw_params = hdmi_audio_hw_params,
738 .trigger = hdmi_audio_trigger,
739 .startup = hdmi_audio_startup,
740};
741
742static struct snd_soc_dai_driver hdmi_codec_dai_drv = {
743 .name = "hdmi-audio-codec",
744 .playback = {
745 .channels_min = 2,
746 .channels_max = 2,
747 .rates = SNDRV_PCM_RATE_32000 |
748 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000,
749 .formats = SNDRV_PCM_FMTBIT_S16_LE |
750 SNDRV_PCM_FMTBIT_S24_LE,
751 },
752 .ops = &hdmi_audio_codec_ops,
753};
754#endif
755
756static int hdmi_get_clocks(struct platform_device *pdev) 536static int hdmi_get_clocks(struct platform_device *pdev)
757{ 537{
758 struct clk *clk; 538 struct clk *clk;
@@ -841,17 +621,6 @@ static int __init omapdss_hdmihw_probe(struct platform_device *pdev)
841 621
842 hdmi_probe_pdata(pdev); 622 hdmi_probe_pdata(pdev);
843 623
844#if defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI) || \
845 defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI_MODULE)
846
847 /* Register ASoC codec DAI */
848 r = snd_soc_register_codec(&pdev->dev, &hdmi_audio_codec_drv,
849 &hdmi_codec_dai_drv, 1);
850 if (r) {
851 DSSERR("can't register ASoC HDMI audio codec\n");
852 return r;
853 }
854#endif
855 return 0; 624 return 0;
856} 625}
857 626
@@ -861,11 +630,6 @@ static int __exit omapdss_hdmihw_remove(struct platform_device *pdev)
861 630
862 hdmi_panel_exit(); 631 hdmi_panel_exit();
863 632
864#if defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI) || \
865 defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI_MODULE)
866 snd_soc_unregister_codec(&pdev->dev);
867#endif
868
869 pm_runtime_disable(&pdev->dev); 633 pm_runtime_disable(&pdev->dev);
870 634
871 hdmi_put_clocks(); 635 hdmi_put_clocks();
diff --git a/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.h b/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.h
index b724bc68307a..bc221435a984 100644
--- a/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.h
+++ b/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.h
@@ -24,11 +24,6 @@
24#include <linux/string.h> 24#include <linux/string.h>
25#include <video/omapdss.h> 25#include <video/omapdss.h>
26#include "ti_hdmi.h" 26#include "ti_hdmi.h"
27#if defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI) || \
28 defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI_MODULE)
29#include <sound/soc.h>
30#include <sound/pcm_params.h>
31#endif
32 27
33/* HDMI Wrapper */ 28/* HDMI Wrapper */
34 29