snd_ps3.c (96916090f488986a4ebb8e9ffa6a3b50881d5ccd) | snd_ps3.c (1ee2a322b058f6399dc900603f9ebb392037ff77) |
---|---|
1/* 2 * Audio support for PS3 3 * Copyright (C) 2007 Sony Computer Entertainment Inc. 4 * All rights reserved. 5 * Copyright 2006, 2007 Sony Corporation 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License --- 652 unchanged lines hidden (view full) --- 661{ 662 int ret; 663 pr_debug("%s: start\n", __func__); 664 card->avs.avs_audio_ch = PS3AV_CMD_AUDIO_NUM_OF_CH_2; 665 card->avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_48K; 666 card->avs.avs_audio_width = PS3AV_CMD_AUDIO_WORD_BITS_16; 667 card->avs.avs_audio_format = PS3AV_CMD_AUDIO_FORMAT_PCM; 668 card->avs.avs_audio_source = PS3AV_CMD_AUDIO_SOURCE_SERIAL; | 1/* 2 * Audio support for PS3 3 * Copyright (C) 2007 Sony Computer Entertainment Inc. 4 * All rights reserved. 5 * Copyright 2006, 2007 Sony Corporation 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License --- 652 unchanged lines hidden (view full) --- 661{ 662 int ret; 663 pr_debug("%s: start\n", __func__); 664 card->avs.avs_audio_ch = PS3AV_CMD_AUDIO_NUM_OF_CH_2; 665 card->avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_48K; 666 card->avs.avs_audio_width = PS3AV_CMD_AUDIO_WORD_BITS_16; 667 card->avs.avs_audio_format = PS3AV_CMD_AUDIO_FORMAT_PCM; 668 card->avs.avs_audio_source = PS3AV_CMD_AUDIO_SOURCE_SERIAL; |
669 memcpy(card->avs.avs_cs_info, ps3av_mode_cs_info, 8); |
|
669 670 ret = snd_ps3_change_avsetting(card); 671 672 snd_ps3_audio_fixup(card); 673 674 /* to start to generate SPDIF signal, fill data */ 675 snd_ps3_program_dma(card, SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL); 676 snd_ps3_kick_dma(card); 677 pr_debug("%s: end\n", __func__); 678 return ret; 679} 680 681/* 682 * set sampling rate according to the substream 683 */ 684static int snd_ps3_set_avsetting(struct snd_pcm_substream *substream) 685{ 686 struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream); 687 struct snd_ps3_avsetting_info avs; | 670 671 ret = snd_ps3_change_avsetting(card); 672 673 snd_ps3_audio_fixup(card); 674 675 /* to start to generate SPDIF signal, fill data */ 676 snd_ps3_program_dma(card, SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL); 677 snd_ps3_kick_dma(card); 678 pr_debug("%s: end\n", __func__); 679 return ret; 680} 681 682/* 683 * set sampling rate according to the substream 684 */ 685static int snd_ps3_set_avsetting(struct snd_pcm_substream *substream) 686{ 687 struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream); 688 struct snd_ps3_avsetting_info avs; |
689 int ret; |
|
688 689 avs = card->avs; 690 691 pr_debug("%s: called freq=%d width=%d\n", __func__, 692 substream->runtime->rate, 693 snd_pcm_format_width(substream->runtime->format)); 694 695 pr_debug("%s: before freq=%d width=%d\n", __func__, --- 28 unchanged lines hidden (view full) --- 724 avs.avs_audio_width = PS3AV_CMD_AUDIO_WORD_BITS_24; 725 break; 726 default: 727 pr_info("%s: invalid width %d\n", __func__, 728 snd_pcm_format_width(substream->runtime->format)); 729 return 1; 730 } 731 | 690 691 avs = card->avs; 692 693 pr_debug("%s: called freq=%d width=%d\n", __func__, 694 substream->runtime->rate, 695 snd_pcm_format_width(substream->runtime->format)); 696 697 pr_debug("%s: before freq=%d width=%d\n", __func__, --- 28 unchanged lines hidden (view full) --- 726 avs.avs_audio_width = PS3AV_CMD_AUDIO_WORD_BITS_24; 727 break; 728 default: 729 pr_info("%s: invalid width %d\n", __func__, 730 snd_pcm_format_width(substream->runtime->format)); 731 return 1; 732 } 733 |
732 if ((card->avs.avs_audio_width != avs.avs_audio_width) || 733 (card->avs.avs_audio_rate != avs.avs_audio_rate)) { 734 card->avs = avs; 735 snd_ps3_change_avsetting(card); | 734 memcpy(avs.avs_cs_info, ps3av_mode_cs_info, 8); |
736 | 735 |
736 if (memcmp(&card->avs, &avs, sizeof(avs))) { |
|
737 pr_debug("%s: after freq=%d width=%d\n", __func__, 738 card->avs.avs_audio_rate, card->avs.avs_audio_width); 739 | 737 pr_debug("%s: after freq=%d width=%d\n", __func__, 738 card->avs.avs_audio_rate, card->avs.avs_audio_width); 739 |
740 return 0; | 740 card->avs = avs; 741 snd_ps3_change_avsetting(card); 742 ret = 0; |
741 } else | 743 } else |
744 ret = 1; 745 746 /* check CS non-audio bit and mute accordingly */ 747 if (avs.avs_cs_info[0] & 0x02) 748 ps3av_audio_mute_analog(1); /* mute if non-audio */ 749 else 750 ps3av_audio_mute_analog(0); 751 752 return ret; 753} 754 755/* 756 * SPDIF status bits controls 757 */ 758static int snd_ps3_spdif_mask_info(struct snd_kcontrol *kcontrol, 759 struct snd_ctl_elem_info *uinfo) 760{ 761 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; 762 uinfo->count = 1; 763 return 0; 764} 765 766/* FIXME: ps3av_set_audio_mode() assumes only consumer mode */ 767static int snd_ps3_spdif_cmask_get(struct snd_kcontrol *kcontrol, 768 struct snd_ctl_elem_value *ucontrol) 769{ 770 memset(ucontrol->value.iec958.status, 0xff, 8); 771 return 0; 772} 773 774static int snd_ps3_spdif_pmask_get(struct snd_kcontrol *kcontrol, 775 struct snd_ctl_elem_value *ucontrol) 776{ 777 return 0; 778} 779 780static int snd_ps3_spdif_default_get(struct snd_kcontrol *kcontrol, 781 struct snd_ctl_elem_value *ucontrol) 782{ 783 memcpy(ucontrol->value.iec958.status, ps3av_mode_cs_info, 8); 784 return 0; 785} 786 787static int snd_ps3_spdif_default_put(struct snd_kcontrol *kcontrol, 788 struct snd_ctl_elem_value *ucontrol) 789{ 790 if (memcmp(ps3av_mode_cs_info, ucontrol->value.iec958.status, 8)) { 791 memcpy(ps3av_mode_cs_info, ucontrol->value.iec958.status, 8); |
|
742 return 1; | 792 return 1; |
793 } 794 return 0; |
|
743} 744 | 795} 796 |
797static struct snd_kcontrol_new spdif_ctls[] = { 798 { 799 .access = SNDRV_CTL_ELEM_ACCESS_READ, 800 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 801 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK), 802 .info = snd_ps3_spdif_mask_info, 803 .get = snd_ps3_spdif_cmask_get, 804 }, 805 { 806 .access = SNDRV_CTL_ELEM_ACCESS_READ, 807 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 808 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PRO_MASK), 809 .info = snd_ps3_spdif_mask_info, 810 .get = snd_ps3_spdif_pmask_get, 811 }, 812 { 813 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 814 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 815 .info = snd_ps3_spdif_mask_info, 816 .get = snd_ps3_spdif_default_get, 817 .put = snd_ps3_spdif_default_put, 818 }, 819}; |
|
745 746 747static int snd_ps3_map_mmio(void) 748{ 749 the_card.mapped_mmio_vaddr = 750 ioremap(the_card.ps3_dev->m_region->bus_addr, 751 the_card.ps3_dev->m_region->len); 752 --- 84 unchanged lines hidden (view full) --- 837 ret = lv1_gpu_attribute(0x100, 0x007, val, 0, 0); 838 if (ret) 839 pr_info("%s: gpu_attribute failed %d\n", __func__, 840 ret); 841} 842 843static int __init snd_ps3_driver_probe(struct ps3_system_bus_device *dev) 844{ | 820 821 822static int snd_ps3_map_mmio(void) 823{ 824 the_card.mapped_mmio_vaddr = 825 ioremap(the_card.ps3_dev->m_region->bus_addr, 826 the_card.ps3_dev->m_region->len); 827 --- 84 unchanged lines hidden (view full) --- 912 ret = lv1_gpu_attribute(0x100, 0x007, val, 0, 0); 913 if (ret) 914 pr_info("%s: gpu_attribute failed %d\n", __func__, 915 ret); 916} 917 918static int __init snd_ps3_driver_probe(struct ps3_system_bus_device *dev) 919{ |
845 int ret; | 920 int i, ret; |
846 u64 lpar_addr, lpar_size; 847 848 BUG_ON(!firmware_has_feature(FW_FEATURE_PS3_LV1)); 849 BUG_ON(dev->match_id != PS3_MATCH_ID_SOUND); 850 851 the_card.ps3_dev = dev; 852 853 ret = ps3_open_hv_device(dev); --- 44 unchanged lines hidden (view full) --- 898 if (!the_card.card) { 899 ret = -ENXIO; 900 goto clean_irq; 901 } 902 903 strcpy(the_card.card->driver, "PS3"); 904 strcpy(the_card.card->shortname, "PS3"); 905 strcpy(the_card.card->longname, "PS3 sound"); | 921 u64 lpar_addr, lpar_size; 922 923 BUG_ON(!firmware_has_feature(FW_FEATURE_PS3_LV1)); 924 BUG_ON(dev->match_id != PS3_MATCH_ID_SOUND); 925 926 the_card.ps3_dev = dev; 927 928 ret = ps3_open_hv_device(dev); --- 44 unchanged lines hidden (view full) --- 973 if (!the_card.card) { 974 ret = -ENXIO; 975 goto clean_irq; 976 } 977 978 strcpy(the_card.card->driver, "PS3"); 979 strcpy(the_card.card->shortname, "PS3"); 980 strcpy(the_card.card->longname, "PS3 sound"); |
981 982 /* create control elements */ 983 for (i = 0; i < ARRAY_SIZE(spdif_ctls); i++) { 984 ret = snd_ctl_add(the_card.card, 985 snd_ctl_new1(&spdif_ctls[i], &the_card)); 986 if (ret < 0) 987 goto clean_card; 988 } 989 |
|
906 /* create PCM devices instance */ 907 /* NOTE:this driver works assuming pcm:substream = 1:1 */ 908 ret = snd_pcm_new(the_card.card, 909 "SPDIF", 910 0, /* instance index, will be stored pcm.device*/ 911 1, /* output substream */ 912 0, /* input substream */ 913 &(the_card.pcm)); --- 211 unchanged lines hidden --- | 990 /* create PCM devices instance */ 991 /* NOTE:this driver works assuming pcm:substream = 1:1 */ 992 ret = snd_pcm_new(the_card.card, 993 "SPDIF", 994 0, /* instance index, will be stored pcm.device*/ 995 1, /* output substream */ 996 0, /* input substream */ 997 &(the_card.pcm)); --- 211 unchanged lines hidden --- |