summaryrefslogtreecommitdiffstats
path: root/sound/x86
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2017-02-04 16:05:33 -0500
committerTakashi Iwai <tiwai@suse.de>2017-02-05 02:49:35 -0500
commitb556290f9a8386ff6afeec12cae29fbab77321a3 (patch)
treef28bbb13402d98477f1534033fafbc9832b3a7e1 /sound/x86
parentf4566aa112b86649b74f3d64c21ec2c8a84d5c1d (diff)
ALSA: x86: Unify local function prefix
Use had_ prefix consistently to all local helper functions, as well as had_pcm_ for PCM ops. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/x86')
-rw-r--r--sound/x86/intel_hdmi_audio.c127
1 files changed, 60 insertions, 67 deletions
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 0a9c82aca05f..57042ef3a480 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -130,7 +130,7 @@ static const struct channel_map_table map_tables[] = {
130}; 130};
131 131
132/* hardware capability structure */ 132/* hardware capability structure */
133static const struct snd_pcm_hardware snd_intel_hadstream = { 133static const struct snd_pcm_hardware had_pcm_hardware = {
134 .info = (SNDRV_PCM_INFO_INTERLEAVED | 134 .info = (SNDRV_PCM_INFO_INTERLEAVED |
135 SNDRV_PCM_INFO_DOUBLE | 135 SNDRV_PCM_INFO_DOUBLE |
136 SNDRV_PCM_INFO_MMAP| 136 SNDRV_PCM_INFO_MMAP|
@@ -213,9 +213,9 @@ static void had_write_register(struct snd_intelhad *ctx, u32 reg, u32 val)
213 * bad audio. The fix is to always write the AUD_CONFIG[6:4] with 213 * bad audio. The fix is to always write the AUD_CONFIG[6:4] with
214 * appropriate value when doing read-modify of AUD_CONFIG register. 214 * appropriate value when doing read-modify of AUD_CONFIG register.
215 */ 215 */
216static void snd_intelhad_enable_audio(struct snd_pcm_substream *substream, 216static void had_enable_audio(struct snd_pcm_substream *substream,
217 struct snd_intelhad *intelhaddata, 217 struct snd_intelhad *intelhaddata,
218 bool enable) 218 bool enable)
219{ 219{
220 union aud_cfg cfg_val = {.regval = 0}; 220 union aud_cfg cfg_val = {.regval = 0};
221 u8 channels; 221 u8 channels;
@@ -240,7 +240,7 @@ static void snd_intelhad_enable_audio(struct snd_pcm_substream *substream,
240} 240}
241 241
242/* enable / disable the audio interface */ 242/* enable / disable the audio interface */
243static void snd_intelhad_enable_audio_int(struct snd_intelhad *ctx, bool enable) 243static void had_enable_audio_int(struct snd_intelhad *ctx, bool enable)
244{ 244{
245 u32 status_reg; 245 u32 status_reg;
246 246
@@ -332,8 +332,8 @@ static int had_prog_status_reg(struct snd_pcm_substream *substream,
332 * registers and buffer confgiuration registers 332 * registers and buffer confgiuration registers
333 * This function is called in the prepare callback 333 * This function is called in the prepare callback
334 */ 334 */
335static int snd_intelhad_audio_ctrl(struct snd_pcm_substream *substream, 335static int had_init_audio_ctrl(struct snd_pcm_substream *substream,
336 struct snd_intelhad *intelhaddata) 336 struct snd_intelhad *intelhaddata)
337{ 337{
338 union aud_cfg cfg_val = {.regval = 0}; 338 union aud_cfg cfg_val = {.regval = 0};
339 union aud_buf_config buf_cfg = {.regval = 0}; 339 union aud_buf_config buf_cfg = {.regval = 0};
@@ -393,8 +393,8 @@ static void init_channel_allocations(void)
393 * 393 *
394 * TODO: it could select the wrong CA from multiple candidates. 394 * TODO: it could select the wrong CA from multiple candidates.
395 */ 395 */
396static int snd_intelhad_channel_allocation(struct snd_intelhad *intelhaddata, 396static int had_channel_allocation(struct snd_intelhad *intelhaddata,
397 int channels) 397 int channels)
398{ 398{
399 int i; 399 int i;
400 int ca = 0; 400 int ca = 0;
@@ -573,8 +573,8 @@ static int had_register_chmap_ctls(struct snd_intelhad *intelhaddata,
573 * Initialize Data Island Packets registers 573 * Initialize Data Island Packets registers
574 * This function is called in the prepare callback 574 * This function is called in the prepare callback
575 */ 575 */
576static void snd_intelhad_prog_dip(struct snd_pcm_substream *substream, 576static void had_prog_dip(struct snd_pcm_substream *substream,
577 struct snd_intelhad *intelhaddata) 577 struct snd_intelhad *intelhaddata)
578{ 578{
579 int i; 579 int i;
580 union aud_ctrl_st ctrl_state = {.regval = 0}; 580 union aud_ctrl_st ctrl_state = {.regval = 0};
@@ -589,7 +589,7 @@ static void snd_intelhad_prog_dip(struct snd_pcm_substream *substream,
589 589
590 had_write_register(intelhaddata, AUD_CNTL_ST, ctrl_state.regval); 590 had_write_register(intelhaddata, AUD_CNTL_ST, ctrl_state.regval);
591 591
592 ca = snd_intelhad_channel_allocation(intelhaddata, channels); 592 ca = had_channel_allocation(intelhaddata, channels);
593 if (intelhaddata->dp_output) { 593 if (intelhaddata->dp_output) {
594 info_frame = DP_INFO_FRAME_WORD1; 594 info_frame = DP_INFO_FRAME_WORD1;
595 frame2.regval = (substream->runtime->channels - 1) | (ca << 24); 595 frame2.regval = (substream->runtime->channels - 1) | (ca << 24);
@@ -782,14 +782,14 @@ static int had_calculate_maud_value(u32 aud_samp_freq, u32 link_rate)
782 * 782 *
783 * @aud_samp_freq: sampling frequency of audio data 783 * @aud_samp_freq: sampling frequency of audio data
784 * @tmds: sampling frequency of the display data 784 * @tmds: sampling frequency of the display data
785 * @link_rate: DP link rate
785 * @n_param: N value, depends on aud_samp_freq 786 * @n_param: N value, depends on aud_samp_freq
786 * @intelhaddata:substream private data 787 * @intelhaddata: substream private data
787 * 788 *
788 * Program CTS register based on the audio and display sampling frequency 789 * Program CTS register based on the audio and display sampling frequency
789 */ 790 */
790static void snd_intelhad_prog_cts(u32 aud_samp_freq, u32 tmds, 791static void had_prog_cts(u32 aud_samp_freq, u32 tmds, u32 link_rate,
791 u32 link_rate, u32 n_param, 792 u32 n_param, struct snd_intelhad *intelhaddata)
792 struct snd_intelhad *intelhaddata)
793{ 793{
794 u32 cts_val; 794 u32 cts_val;
795 u64 dividend, divisor; 795 u64 dividend, divisor;
@@ -854,13 +854,13 @@ static int had_calculate_n_value(u32 aud_samp_freq)
854 * 854 *
855 * @aud_samp_freq: sampling frequency of audio data 855 * @aud_samp_freq: sampling frequency of audio data
856 * @n_param: N value, depends on aud_samp_freq 856 * @n_param: N value, depends on aud_samp_freq
857 * @intelhaddata:substream private data 857 * @intelhaddata: substream private data
858 * 858 *
859 * This function is called in the prepare callback. 859 * This function is called in the prepare callback.
860 * It programs based on the audio and display sampling frequency 860 * It programs based on the audio and display sampling frequency
861 */ 861 */
862static int snd_intelhad_prog_n(u32 aud_samp_freq, u32 *n_param, 862static int had_prog_n(u32 aud_samp_freq, u32 *n_param,
863 struct snd_intelhad *intelhaddata) 863 struct snd_intelhad *intelhaddata)
864{ 864{
865 int n_val; 865 int n_val;
866 866
@@ -917,7 +917,7 @@ static void snd_intelhad_handle_underrun(struct snd_intelhad *intelhaddata)
917/* 917/*
918 * ALSA PCM open callback 918 * ALSA PCM open callback
919 */ 919 */
920static int snd_intelhad_open(struct snd_pcm_substream *substream) 920static int had_pcm_open(struct snd_pcm_substream *substream)
921{ 921{
922 struct snd_intelhad *intelhaddata; 922 struct snd_intelhad *intelhaddata;
923 struct snd_pcm_runtime *runtime; 923 struct snd_pcm_runtime *runtime;
@@ -936,7 +936,7 @@ static int snd_intelhad_open(struct snd_pcm_substream *substream)
936 } 936 }
937 937
938 /* set the runtime hw parameter with local snd_pcm_hardware struct */ 938 /* set the runtime hw parameter with local snd_pcm_hardware struct */
939 runtime->hw = snd_intel_hadstream; 939 runtime->hw = had_pcm_hardware;
940 940
941 retval = snd_pcm_hw_constraint_integer(runtime, 941 retval = snd_pcm_hw_constraint_integer(runtime,
942 SNDRV_PCM_HW_PARAM_PERIODS); 942 SNDRV_PCM_HW_PARAM_PERIODS);
@@ -971,7 +971,7 @@ static int snd_intelhad_open(struct snd_pcm_substream *substream)
971/* 971/*
972 * ALSA PCM close callback 972 * ALSA PCM close callback
973 */ 973 */
974static int snd_intelhad_close(struct snd_pcm_substream *substream) 974static int had_pcm_close(struct snd_pcm_substream *substream)
975{ 975{
976 struct snd_intelhad *intelhaddata; 976 struct snd_intelhad *intelhaddata;
977 977
@@ -995,8 +995,8 @@ static int snd_intelhad_close(struct snd_pcm_substream *substream)
995/* 995/*
996 * ALSA PCM hw_params callback 996 * ALSA PCM hw_params callback
997 */ 997 */
998static int snd_intelhad_hw_params(struct snd_pcm_substream *substream, 998static int had_pcm_hw_params(struct snd_pcm_substream *substream,
999 struct snd_pcm_hw_params *hw_params) 999 struct snd_pcm_hw_params *hw_params)
1000{ 1000{
1001 struct snd_intelhad *intelhaddata; 1001 struct snd_intelhad *intelhaddata;
1002 unsigned long addr; 1002 unsigned long addr;
@@ -1026,7 +1026,7 @@ static int snd_intelhad_hw_params(struct snd_pcm_substream *substream,
1026/* 1026/*
1027 * ALSA PCM hw_free callback 1027 * ALSA PCM hw_free callback
1028 */ 1028 */
1029static int snd_intelhad_hw_free(struct snd_pcm_substream *substream) 1029static int had_pcm_hw_free(struct snd_pcm_substream *substream)
1030{ 1030{
1031 unsigned long addr; 1031 unsigned long addr;
1032 u32 pages; 1032 u32 pages;
@@ -1045,8 +1045,7 @@ static int snd_intelhad_hw_free(struct snd_pcm_substream *substream)
1045/* 1045/*
1046 * ALSA PCM trigger callback 1046 * ALSA PCM trigger callback
1047 */ 1047 */
1048static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream, 1048static int had_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1049 int cmd)
1050{ 1049{
1051 int retval = 0; 1050 int retval = 0;
1052 struct snd_intelhad *intelhaddata; 1051 struct snd_intelhad *intelhaddata;
@@ -1068,8 +1067,8 @@ static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream,
1068 intelhaddata->stream_info.running = true; 1067 intelhaddata->stream_info.running = true;
1069 1068
1070 /* Enable Audio */ 1069 /* Enable Audio */
1071 snd_intelhad_enable_audio_int(intelhaddata, true); 1070 had_enable_audio_int(intelhaddata, true);
1072 snd_intelhad_enable_audio(substream, intelhaddata, true); 1071 had_enable_audio(substream, intelhaddata, true);
1073 break; 1072 break;
1074 1073
1075 case SNDRV_PCM_TRIGGER_STOP: 1074 case SNDRV_PCM_TRIGGER_STOP:
@@ -1082,11 +1081,11 @@ static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream,
1082 intelhaddata->stream_info.running = false; 1081 intelhaddata->stream_info.running = false;
1083 spin_unlock(&intelhaddata->had_spinlock); 1082 spin_unlock(&intelhaddata->had_spinlock);
1084 /* Disable Audio */ 1083 /* Disable Audio */
1085 snd_intelhad_enable_audio_int(intelhaddata, false); 1084 had_enable_audio_int(intelhaddata, false);
1086 snd_intelhad_enable_audio(substream, intelhaddata, false); 1085 had_enable_audio(substream, intelhaddata, false);
1087 /* Reset buffer pointers */ 1086 /* Reset buffer pointers */
1088 had_reset_audio(intelhaddata); 1087 had_reset_audio(intelhaddata);
1089 snd_intelhad_enable_audio_int(intelhaddata, false); 1088 had_enable_audio_int(intelhaddata, false);
1090 break; 1089 break;
1091 1090
1092 default: 1091 default:
@@ -1098,7 +1097,7 @@ static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream,
1098/* 1097/*
1099 * ALSA PCM prepare callback 1098 * ALSA PCM prepare callback
1100 */ 1099 */
1101static int snd_intelhad_pcm_prepare(struct snd_pcm_substream *substream) 1100static int had_pcm_prepare(struct snd_pcm_substream *substream)
1102{ 1101{
1103 int retval; 1102 int retval;
1104 u32 disp_samp_freq, n_param; 1103 u32 disp_samp_freq, n_param;
@@ -1131,8 +1130,7 @@ static int snd_intelhad_pcm_prepare(struct snd_pcm_substream *substream)
1131 /* Get N value in KHz */ 1130 /* Get N value in KHz */
1132 disp_samp_freq = intelhaddata->tmds_clock_speed; 1131 disp_samp_freq = intelhaddata->tmds_clock_speed;
1133 1132
1134 retval = snd_intelhad_prog_n(substream->runtime->rate, &n_param, 1133 retval = had_prog_n(substream->runtime->rate, &n_param, intelhaddata);
1135 intelhaddata);
1136 if (retval) { 1134 if (retval) {
1137 dev_err(intelhaddata->dev, 1135 dev_err(intelhaddata->dev,
1138 "programming N value failed %#x\n", retval); 1136 "programming N value failed %#x\n", retval);
@@ -1142,13 +1140,12 @@ static int snd_intelhad_pcm_prepare(struct snd_pcm_substream *substream)
1142 if (intelhaddata->dp_output) 1140 if (intelhaddata->dp_output)
1143 link_rate = intelhaddata->link_rate; 1141 link_rate = intelhaddata->link_rate;
1144 1142
1145 snd_intelhad_prog_cts(substream->runtime->rate, 1143 had_prog_cts(substream->runtime->rate, disp_samp_freq, link_rate,
1146 disp_samp_freq, link_rate, 1144 n_param, intelhaddata);
1147 n_param, intelhaddata);
1148 1145
1149 snd_intelhad_prog_dip(substream, intelhaddata); 1146 had_prog_dip(substream, intelhaddata);
1150 1147
1151 retval = snd_intelhad_audio_ctrl(substream, intelhaddata); 1148 retval = had_init_audio_ctrl(substream, intelhaddata);
1152 1149
1153 /* Prog buffer address */ 1150 /* Prog buffer address */
1154 retval = snd_intelhad_prog_buffer(substream, intelhaddata, 1151 retval = snd_intelhad_prog_buffer(substream, intelhaddata,
@@ -1168,8 +1165,7 @@ prep_end:
1168/* 1165/*
1169 * ALSA PCM pointer callback 1166 * ALSA PCM pointer callback
1170 */ 1167 */
1171static snd_pcm_uframes_t 1168static snd_pcm_uframes_t had_pcm_pointer(struct snd_pcm_substream *substream)
1172snd_intelhad_pcm_pointer(struct snd_pcm_substream *substream)
1173{ 1169{
1174 struct snd_intelhad *intelhaddata; 1170 struct snd_intelhad *intelhaddata;
1175 u32 bytes_rendered = 0; 1171 u32 bytes_rendered = 0;
@@ -1219,8 +1215,8 @@ snd_intelhad_pcm_pointer(struct snd_pcm_substream *substream)
1219/* 1215/*
1220 * ALSA PCM mmap callback 1216 * ALSA PCM mmap callback
1221 */ 1217 */
1222static int snd_intelhad_pcm_mmap(struct snd_pcm_substream *substream, 1218static int had_pcm_mmap(struct snd_pcm_substream *substream,
1223 struct vm_area_struct *vma) 1219 struct vm_area_struct *vma)
1224{ 1220{
1225 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 1221 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
1226 return remap_pfn_range(vma, vma->vm_start, 1222 return remap_pfn_range(vma, vma->vm_start,
@@ -1231,20 +1227,20 @@ static int snd_intelhad_pcm_mmap(struct snd_pcm_substream *substream,
1231/* 1227/*
1232 * ALSA PCM ops 1228 * ALSA PCM ops
1233 */ 1229 */
1234static const struct snd_pcm_ops snd_intelhad_playback_ops = { 1230static const struct snd_pcm_ops had_pcm_ops = {
1235 .open = snd_intelhad_open, 1231 .open = had_pcm_open,
1236 .close = snd_intelhad_close, 1232 .close = had_pcm_close,
1237 .ioctl = snd_pcm_lib_ioctl, 1233 .ioctl = snd_pcm_lib_ioctl,
1238 .hw_params = snd_intelhad_hw_params, 1234 .hw_params = had_pcm_hw_params,
1239 .hw_free = snd_intelhad_hw_free, 1235 .hw_free = had_pcm_hw_free,
1240 .prepare = snd_intelhad_pcm_prepare, 1236 .prepare = had_pcm_prepare,
1241 .trigger = snd_intelhad_pcm_trigger, 1237 .trigger = had_pcm_trigger,
1242 .pointer = snd_intelhad_pcm_pointer, 1238 .pointer = had_pcm_pointer,
1243 .mmap = snd_intelhad_pcm_mmap, 1239 .mmap = had_pcm_mmap,
1244}; 1240};
1245 1241
1246/* process mode change of the running stream; called in mutex */ 1242/* process mode change of the running stream; called in mutex */
1247static int hdmi_audio_mode_change(struct snd_intelhad *intelhaddata) 1243static int had_process_mode_change(struct snd_intelhad *intelhaddata)
1248{ 1244{
1249 struct snd_pcm_substream *substream; 1245 struct snd_pcm_substream *substream;
1250 int retval = 0; 1246 int retval = 0;
@@ -1256,13 +1252,12 @@ static int hdmi_audio_mode_change(struct snd_intelhad *intelhaddata)
1256 return 0; 1252 return 0;
1257 1253
1258 /* Disable Audio */ 1254 /* Disable Audio */
1259 snd_intelhad_enable_audio(substream, intelhaddata, false); 1255 had_enable_audio(substream, intelhaddata, false);
1260 1256
1261 /* Update CTS value */ 1257 /* Update CTS value */
1262 disp_samp_freq = intelhaddata->tmds_clock_speed; 1258 disp_samp_freq = intelhaddata->tmds_clock_speed;
1263 1259
1264 retval = snd_intelhad_prog_n(substream->runtime->rate, &n_param, 1260 retval = had_prog_n(substream->runtime->rate, &n_param, intelhaddata);
1265 intelhaddata);
1266 if (retval) { 1261 if (retval) {
1267 dev_err(intelhaddata->dev, 1262 dev_err(intelhaddata->dev,
1268 "programming N value failed %#x\n", retval); 1263 "programming N value failed %#x\n", retval);
@@ -1272,12 +1267,11 @@ static int hdmi_audio_mode_change(struct snd_intelhad *intelhaddata)
1272 if (intelhaddata->dp_output) 1267 if (intelhaddata->dp_output)
1273 link_rate = intelhaddata->link_rate; 1268 link_rate = intelhaddata->link_rate;
1274 1269
1275 snd_intelhad_prog_cts(substream->runtime->rate, 1270 had_prog_cts(substream->runtime->rate, disp_samp_freq, link_rate,
1276 disp_samp_freq, link_rate, 1271 n_param, intelhaddata);
1277 n_param, intelhaddata);
1278 1272
1279 /* Enable Audio */ 1273 /* Enable Audio */
1280 snd_intelhad_enable_audio(substream, intelhaddata, true); 1274 had_enable_audio(substream, intelhaddata, true);
1281 1275
1282out: 1276out:
1283 had_substream_put(intelhaddata); 1277 had_substream_put(intelhaddata);
@@ -1510,8 +1504,8 @@ static void had_process_hot_unplug(struct snd_intelhad *intelhaddata)
1510 } 1504 }
1511 1505
1512 /* Disable Audio */ 1506 /* Disable Audio */
1513 snd_intelhad_enable_audio_int(intelhaddata, false); 1507 had_enable_audio_int(intelhaddata, false);
1514 snd_intelhad_enable_audio(substream, intelhaddata, false); 1508 had_enable_audio(substream, intelhaddata, false);
1515 1509
1516 intelhaddata->connected = false; 1510 intelhaddata->connected = false;
1517 dev_dbg(intelhaddata->dev, 1511 dev_dbg(intelhaddata->dev,
@@ -1712,7 +1706,7 @@ static void had_audio_wq(struct work_struct *work)
1712 had_process_hot_plug(ctx); 1706 had_process_hot_plug(ctx);
1713 1707
1714 /* Process mode change if stream is active */ 1708 /* Process mode change if stream is active */
1715 hdmi_audio_mode_change(ctx); 1709 had_process_mode_change(ctx);
1716 } 1710 }
1717 mutex_unlock(&ctx->mutex); 1711 mutex_unlock(&ctx->mutex);
1718 pm_runtime_put(ctx->dev); 1712 pm_runtime_put(ctx->dev);
@@ -1862,8 +1856,7 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
1862 pcm->info_flags = 0; 1856 pcm->info_flags = 0;
1863 strncpy(pcm->name, card->shortname, strlen(card->shortname)); 1857 strncpy(pcm->name, card->shortname, strlen(card->shortname));
1864 /* setup the ops for playabck */ 1858 /* setup the ops for playabck */
1865 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, 1859 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &had_pcm_ops);
1866 &snd_intelhad_playback_ops);
1867 1860
1868 /* only 32bit addressable */ 1861 /* only 32bit addressable */
1869 dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); 1862 dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
@@ -1923,7 +1916,7 @@ static int hdmi_lpe_audio_remove(struct platform_device *pdev)
1923 struct snd_intelhad *ctx = platform_get_drvdata(pdev); 1916 struct snd_intelhad *ctx = platform_get_drvdata(pdev);
1924 1917
1925 if (ctx->connected) 1918 if (ctx->connected)
1926 snd_intelhad_enable_audio_int(ctx, false); 1919 had_enable_audio_int(ctx, false);
1927 snd_card_free(ctx->card); 1920 snd_card_free(ctx->card);
1928 return 0; 1921 return 0;
1929} 1922}