Commit 2e52f5e5 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: x86: Tidy up codes

Clean up codes, fix indentations, correct comments, etc.
No functional change.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 79f439ea
...@@ -285,7 +285,7 @@ static void snd_intelhad_reset_audio(struct snd_intelhad *intelhaddata, ...@@ -285,7 +285,7 @@ static void snd_intelhad_reset_audio(struct snd_intelhad *intelhaddata,
had_write_register(intelhaddata, AUD_HDMI_STATUS_v2, reset); had_write_register(intelhaddata, AUD_HDMI_STATUS_v2, reset);
} }
/** /*
* initialize audio channel status registers * initialize audio channel status registers
* This function is called in the prepare callback * This function is called in the prepare callback
*/ */
...@@ -298,9 +298,9 @@ static int had_prog_status_reg(struct snd_pcm_substream *substream, ...@@ -298,9 +298,9 @@ static int had_prog_status_reg(struct snd_pcm_substream *substream,
int format; int format;
ch_stat0.status_0_regx.lpcm_id = (intelhaddata->aes_bits & ch_stat0.status_0_regx.lpcm_id = (intelhaddata->aes_bits &
IEC958_AES0_NONAUDIO)>>1; IEC958_AES0_NONAUDIO) >> 1;
ch_stat0.status_0_regx.clk_acc = (intelhaddata->aes_bits & ch_stat0.status_0_regx.clk_acc = (intelhaddata->aes_bits &
IEC958_AES3_CON_CLOCK)>>4; IEC958_AES3_CON_CLOCK) >> 4;
cfg_val.cfg_regx_v2.val_bit = ch_stat0.status_0_regx.lpcm_id; cfg_val.cfg_regx_v2.val_bit = ch_stat0.status_0_regx.lpcm_id;
switch (substream->runtime->rate) { switch (substream->runtime->rate) {
...@@ -330,9 +330,8 @@ static int had_prog_status_reg(struct snd_pcm_substream *substream, ...@@ -330,9 +330,8 @@ static int had_prog_status_reg(struct snd_pcm_substream *substream,
default: default:
/* control should never come here */ /* control should never come here */
return -EINVAL; return -EINVAL;
break;
} }
had_write_register(intelhaddata, had_write_register(intelhaddata,
AUD_CH_STATUS_0, ch_stat0.status_0_regval); AUD_CH_STATUS_0, ch_stat0.status_0_regval);
...@@ -348,6 +347,7 @@ static int had_prog_status_reg(struct snd_pcm_substream *substream, ...@@ -348,6 +347,7 @@ static int had_prog_status_reg(struct snd_pcm_substream *substream,
ch_stat1.status_1_regx.max_wrd_len = 0; ch_stat1.status_1_regx.max_wrd_len = 0;
ch_stat1.status_1_regx.wrd_len = 0; ch_stat1.status_1_regx.wrd_len = 0;
} }
had_write_register(intelhaddata, had_write_register(intelhaddata,
AUD_CH_STATUS_1, ch_stat1.status_1_regval); AUD_CH_STATUS_1, ch_stat1.status_1_regval);
return 0; return 0;
...@@ -466,14 +466,14 @@ static int spk_to_chmap(int spk) ...@@ -466,14 +466,14 @@ static int spk_to_chmap(int spk)
static void had_build_channel_allocation_map(struct snd_intelhad *intelhaddata) static void had_build_channel_allocation_map(struct snd_intelhad *intelhaddata)
{ {
int i = 0, c = 0; int i, c;
int spk_mask = 0; int spk_mask = 0;
struct snd_pcm_chmap_elem *chmap; struct snd_pcm_chmap_elem *chmap;
u8 eld_high, eld_high_mask = 0xF0; u8 eld_high, eld_high_mask = 0xF0;
u8 high_msb; u8 high_msb;
chmap = kzalloc(sizeof(*chmap), GFP_KERNEL); chmap = kzalloc(sizeof(*chmap), GFP_KERNEL);
if (chmap == NULL) { if (!chmap) {
intelhaddata->chmap->chmap = NULL; intelhaddata->chmap->chmap = NULL;
return; return;
} }
...@@ -514,7 +514,7 @@ static void had_build_channel_allocation_map(struct snd_intelhad *intelhaddata) ...@@ -514,7 +514,7 @@ static void had_build_channel_allocation_map(struct snd_intelhad *intelhaddata)
for (c = 0; c < channel_allocations[i].channels; c++) { for (c = 0; c < channel_allocations[i].channels; c++) {
chmap->map[c] = spk_to_chmap( chmap->map[c] = spk_to_chmap(
channel_allocations[i].speakers[ channel_allocations[i].speakers[
(MAX_SPEAKERS - 1)-c]); (MAX_SPEAKERS - 1) - c]);
} }
chmap->channels = channel_allocations[i].channels; chmap->channels = channel_allocations[i].channels;
intelhaddata->chmap->chmap = chmap; intelhaddata->chmap->chmap = chmap;
...@@ -550,12 +550,12 @@ static int had_chmap_ctl_get(struct snd_kcontrol *kcontrol, ...@@ -550,12 +550,12 @@ static int had_chmap_ctl_get(struct snd_kcontrol *kcontrol,
{ {
struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
struct snd_intelhad *intelhaddata = info->private_data; struct snd_intelhad *intelhaddata = info->private_data;
int i = 0; int i;
const struct snd_pcm_chmap_elem *chmap; const struct snd_pcm_chmap_elem *chmap;
if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED)
return -ENODEV; return -ENODEV;
if (intelhaddata->chmap->chmap == NULL) if (!intelhaddata->chmap->chmap)
return -ENODATA; return -ENODATA;
chmap = intelhaddata->chmap->chmap; chmap = intelhaddata->chmap->chmap;
for (i = 0; i < chmap->channels; i++) for (i = 0; i < chmap->channels; i++)
...@@ -567,7 +567,7 @@ static int had_chmap_ctl_get(struct snd_kcontrol *kcontrol, ...@@ -567,7 +567,7 @@ static int had_chmap_ctl_get(struct snd_kcontrol *kcontrol,
static int had_register_chmap_ctls(struct snd_intelhad *intelhaddata, static int had_register_chmap_ctls(struct snd_intelhad *intelhaddata,
struct snd_pcm *pcm) struct snd_pcm *pcm)
{ {
int err = 0; int err;
err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
NULL, 0, (unsigned long)intelhaddata, NULL, 0, (unsigned long)intelhaddata,
...@@ -615,7 +615,7 @@ static void snd_intelhad_prog_dip(struct snd_pcm_substream *substream, ...@@ -615,7 +615,7 @@ static void snd_intelhad_prog_dip(struct snd_pcm_substream *substream,
frame3.fr3_regx.chnl_alloc = snd_intelhad_channel_allocation( frame3.fr3_regx.chnl_alloc = snd_intelhad_channel_allocation(
intelhaddata, channels); intelhaddata, channels);
/*Calculte the byte wide checksum for all valid DIP words*/ /* Calculte the byte wide checksum for all valid DIP words */
for (i = 0; i < BYTES_PER_WORD; i++) for (i = 0; i < BYTES_PER_WORD; i++)
checksum += (info_frame >> i*BITS_PER_BYTE) & MASK_BYTE0; checksum += (info_frame >> i*BITS_PER_BYTE) & MASK_BYTE0;
for (i = 0; i < BYTES_PER_WORD; i++) for (i = 0; i < BYTES_PER_WORD; i++)
...@@ -639,10 +639,8 @@ static void snd_intelhad_prog_dip(struct snd_pcm_substream *substream, ...@@ -639,10 +639,8 @@ static void snd_intelhad_prog_dip(struct snd_pcm_substream *substream,
had_write_register(intelhaddata, AUD_CNTL_ST, ctrl_state.ctrl_val); had_write_register(intelhaddata, AUD_CNTL_ST, ctrl_state.ctrl_val);
} }
/** /*
* snd_intelhad_prog_buffer - programs buffer * snd_intelhad_prog_buffer - programs buffer address and length registers
* address and length registers
*
* @substream:substream for which the prepare function is called * @substream:substream for which the prepare function is called
* @intelhaddata:substream private data * @intelhaddata:substream private data
* *
...@@ -684,7 +682,7 @@ static int snd_intelhad_prog_buffer(struct snd_intelhad *intelhaddata, ...@@ -684,7 +682,7 @@ static int snd_intelhad_prog_buffer(struct snd_intelhad *intelhaddata,
intelhaddata->buf_info[i].buf_size = period_bytes; intelhaddata->buf_info[i].buf_size = period_bytes;
else else
intelhaddata->buf_info[i].buf_size = ring_buf_size - intelhaddata->buf_info[i].buf_size = ring_buf_size -
(period_bytes*i); (i * period_bytes);
had_write_register(intelhaddata, had_write_register(intelhaddata,
AUD_BUF_A_ADDR + (i * HAD_REG_WIDTH), AUD_BUF_A_ADDR + (i * HAD_REG_WIDTH),
...@@ -728,7 +726,7 @@ static int had_calculate_maud_value(u32 aud_samp_freq, u32 link_rate) ...@@ -728,7 +726,7 @@ static int had_calculate_maud_value(u32 aud_samp_freq, u32 link_rate)
{ {
u32 maud_val; u32 maud_val;
/* Select maud according to DP 1.2 spec*/ /* Select maud according to DP 1.2 spec */
if (link_rate == DP_2_7_GHZ) { if (link_rate == DP_2_7_GHZ) {
switch (aud_samp_freq) { switch (aud_samp_freq) {
case AUD_SAMPLE_RATE_32: case AUD_SAMPLE_RATE_32:
...@@ -836,7 +834,7 @@ static void snd_intelhad_prog_cts(u32 aud_samp_freq, u32 tmds, ...@@ -836,7 +834,7 @@ static void snd_intelhad_prog_cts(u32 aud_samp_freq, u32 tmds,
static int had_calculate_n_value(u32 aud_samp_freq) static int had_calculate_n_value(u32 aud_samp_freq)
{ {
s32 n_val; int n_val;
/* Select N according to HDMI 1.3a spec*/ /* Select N according to HDMI 1.3a spec*/
switch (aud_samp_freq) { switch (aud_samp_freq) {
...@@ -888,7 +886,7 @@ static int had_calculate_n_value(u32 aud_samp_freq) ...@@ -888,7 +886,7 @@ static int had_calculate_n_value(u32 aud_samp_freq)
static int snd_intelhad_prog_n(u32 aud_samp_freq, u32 *n_param, static int snd_intelhad_prog_n(u32 aud_samp_freq, u32 *n_param,
struct snd_intelhad *intelhaddata) struct snd_intelhad *intelhaddata)
{ {
s32 n_val; int n_val;
if (intelhaddata->dp_output) { if (intelhaddata->dp_output) {
/* /*
...@@ -920,7 +918,7 @@ static void snd_intelhad_handle_underrun(struct snd_intelhad *intelhaddata) ...@@ -920,7 +918,7 @@ static void snd_intelhad_handle_underrun(struct snd_intelhad *intelhaddata)
/* Reset buffer pointers */ /* Reset buffer pointers */
had_write_register(intelhaddata, AUD_HDMI_STATUS_v2, 1); had_write_register(intelhaddata, AUD_HDMI_STATUS_v2, 1);
had_write_register(intelhaddata, AUD_HDMI_STATUS_v2, 0); had_write_register(intelhaddata, AUD_HDMI_STATUS_v2, 0);
/** /*
* The interrupt status 'sticky' bits might not be cleared by * The interrupt status 'sticky' bits might not be cleared by
* setting '1' to that bit once... * setting '1' to that bit once...
*/ */
...@@ -939,7 +937,7 @@ static void snd_intelhad_handle_underrun(struct snd_intelhad *intelhaddata) ...@@ -939,7 +937,7 @@ static void snd_intelhad_handle_underrun(struct snd_intelhad *intelhaddata)
dev_err(intelhaddata->dev, "Unable to clear UNDERRUN bits\n"); dev_err(intelhaddata->dev, "Unable to clear UNDERRUN bits\n");
} }
/** /*
* snd_intelhad_open - stream initializations are done here * snd_intelhad_open - stream initializations are done here
* @substream:substream for which the stream function is called * @substream:substream for which the stream function is called
* *
...@@ -1029,25 +1027,8 @@ static void had_period_elapsed(struct snd_pcm_substream *substream) ...@@ -1029,25 +1027,8 @@ static void had_period_elapsed(struct snd_pcm_substream *substream)
snd_pcm_period_elapsed(substream); snd_pcm_period_elapsed(substream);
} }
/** /*
* snd_intelhad_init_stream - internal function to initialize stream info * snd_intelhad_close - to free parameteres when stream is stopped
* @substream:substream for which the stream function is called
*
*/
static int snd_intelhad_init_stream(struct snd_pcm_substream *substream)
{
struct snd_intelhad *intelhaddata = snd_pcm_substream_chip(substream);
intelhaddata->stream_info.had_substream = substream;
intelhaddata->stream_info.buffer_ptr = 0;
intelhaddata->stream_info.buffer_rendered = 0;
intelhaddata->stream_info.sfreq = substream->runtime->rate;
return 0;
}
/**
* snd_intelhad_close- to free parameteres when stream is stopped
*
* @substream: substream for which the function is called * @substream: substream for which the function is called
* *
* This function is called by ALSA framework when stream is stopped * This function is called by ALSA framework when stream is stopped
...@@ -1081,10 +1062,9 @@ static int snd_intelhad_close(struct snd_pcm_substream *substream) ...@@ -1081,10 +1062,9 @@ static int snd_intelhad_close(struct snd_pcm_substream *substream)
return 0; return 0;
} }
/** /*
* snd_intelhad_hw_params- to setup the hardware parameters * snd_intelhad_hw_params - to setup the hardware parameters
* like allocating the buffers * like allocating the buffers
*
* @substream: substream for which the function is called * @substream: substream for which the function is called
* @hw_params: hardware parameters * @hw_params: hardware parameters
* *
...@@ -1121,14 +1101,12 @@ static int snd_intelhad_hw_params(struct snd_pcm_substream *substream, ...@@ -1121,14 +1101,12 @@ static int snd_intelhad_hw_params(struct snd_pcm_substream *substream,
return retval; return retval;
} }
/** /*
* snd_intelhad_hw_free- to release the resources allocated during * snd_intelhad_hw_free - to release the resources allocated during
* hardware params setup * hardware params setup
*
* @substream: substream for which the function is called * @substream: substream for which the function is called
* *
* This function is called by ALSA framework before close callback. * This function is called by ALSA framework before close callback.
*
*/ */
static int snd_intelhad_hw_free(struct snd_pcm_substream *substream) static int snd_intelhad_hw_free(struct snd_pcm_substream *substream)
{ {
...@@ -1146,10 +1124,11 @@ static int snd_intelhad_hw_free(struct snd_pcm_substream *substream) ...@@ -1146,10 +1124,11 @@ static int snd_intelhad_hw_free(struct snd_pcm_substream *substream)
return 0; return 0;
} }
/** /*
* snd_intelhad_pcm_trigger - stream activities are handled here * snd_intelhad_pcm_trigger - stream activities are handled here
* @substream:substream for which the stream function is called * @substream: substream for which the stream function is called
* @cmd:the stream commamd thats requested from upper layer * @cmd: the stream commamd thats requested from upper layer
*
* This function is called whenever an a stream activity is invoked * This function is called whenever an a stream activity is invoked
*/ */
static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream, static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream,
...@@ -1208,9 +1187,8 @@ static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream, ...@@ -1208,9 +1187,8 @@ static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream,
return retval; return retval;
} }
/** /*
* snd_intelhad_pcm_prepare- internal preparation before starting a stream * snd_intelhad_pcm_prepare - internal preparation before starting a stream
*
* @substream: substream for which the function is called * @substream: substream for which the function is called
* *
* This function is called when a stream is started for internal preparation. * This function is called when a stream is started for internal preparation.
...@@ -1252,10 +1230,10 @@ static int snd_intelhad_pcm_prepare(struct snd_pcm_substream *substream) ...@@ -1252,10 +1230,10 @@ static int snd_intelhad_pcm_prepare(struct snd_pcm_substream *substream)
return retval; return retval;
} }
retval = snd_intelhad_init_stream(substream); intelhaddata->stream_info.had_substream = substream;
if (retval) intelhaddata->stream_info.buffer_ptr = 0;
goto prep_end; intelhaddata->stream_info.buffer_rendered = 0;
intelhaddata->stream_info.sfreq = substream->runtime->rate;
/* Get N value in KHz */ /* Get N value in KHz */
disp_samp_freq = intelhaddata->tmds_clock_speed; disp_samp_freq = intelhaddata->tmds_clock_speed;
...@@ -1294,9 +1272,8 @@ static int snd_intelhad_pcm_prepare(struct snd_pcm_substream *substream) ...@@ -1294,9 +1272,8 @@ static int snd_intelhad_pcm_prepare(struct snd_pcm_substream *substream)
return retval; return retval;
} }
/** /*
* snd_intelhad_pcm_pointer- to send the current buffer pointerprocessed by hw * snd_intelhad_pcm_pointer- to send the current buffer pointerprocessed by hw
*
* @substream: substream for which the function is called * @substream: substream for which the function is called
* *
* This function is called by ALSA framework to get the current hw buffer ptr * This function is called by ALSA framework to get the current hw buffer ptr
...@@ -1359,9 +1336,8 @@ static snd_pcm_uframes_t snd_intelhad_pcm_pointer( ...@@ -1359,9 +1336,8 @@ static snd_pcm_uframes_t snd_intelhad_pcm_pointer(
return intelhaddata->stream_info.buffer_ptr; return intelhaddata->stream_info.buffer_ptr;
} }
/** /*
* snd_intelhad_pcm_mmap- mmaps a kernel buffer to user space for copying data * snd_intelhad_pcm_mmap- mmaps a kernel buffer to user space for copying data
*
* @substream: substream for which the function is called * @substream: substream for which the function is called
* @vma: struct instance of memory VMM memory area * @vma: struct instance of memory VMM memory area
* *
...@@ -1418,11 +1394,9 @@ static int hdmi_audio_mode_change(struct snd_intelhad *intelhaddata) ...@@ -1418,11 +1394,9 @@ static int hdmi_audio_mode_change(struct snd_intelhad *intelhaddata)
/* /*
* hdmi_lpe_audio_suspend - power management suspend function * hdmi_lpe_audio_suspend - power management suspend function
*
* @pdev: platform device * @pdev: platform device
* *
* This function is called by client driver to suspend the * This function is called to suspend the hdmi audio.
* hdmi audio.
*/ */
static int hdmi_lpe_audio_suspend(struct platform_device *pdev, static int hdmi_lpe_audio_suspend(struct platform_device *pdev,
pm_message_t state) pm_message_t state)
...@@ -1465,11 +1439,9 @@ static int hdmi_lpe_audio_suspend(struct platform_device *pdev, ...@@ -1465,11 +1439,9 @@ static int hdmi_lpe_audio_suspend(struct platform_device *pdev,
/* /*
* hdmi_lpe_audio_resume - power management resume function * hdmi_lpe_audio_resume - power management resume function
* @pdev: platform device
* *
*@pdev: platform device * This function is called to resume the hdmi audio.
*
* This function is called by client driver to resume the
* hdmi audio.
*/ */
static int hdmi_lpe_audio_resume(struct platform_device *pdev) static int hdmi_lpe_audio_resume(struct platform_device *pdev)
{ {
...@@ -1605,7 +1577,7 @@ static int had_process_buffer_done(struct snd_intelhad *intelhaddata) ...@@ -1605,7 +1577,7 @@ static int had_process_buffer_done(struct snd_intelhad *intelhaddata)
return 0; return 0;
} }
/*Reprogram the registers with addr and length*/ /* Reprogram the registers with addr and length */
had_write_register(intelhaddata, had_write_register(intelhaddata,
AUD_BUF_A_LENGTH + (buf_id * HAD_REG_WIDTH), AUD_BUF_A_LENGTH + (buf_id * HAD_REG_WIDTH),
buf_size); buf_size);
...@@ -1939,8 +1911,7 @@ static void hdmi_lpe_audio_free(struct snd_card *card) ...@@ -1939,8 +1911,7 @@ static void hdmi_lpe_audio_free(struct snd_card *card)
* hdmi_lpe_audio_probe - start bridge with i915 * hdmi_lpe_audio_probe - start bridge with i915
* *
* This function is called when the i915 driver creates the * This function is called when the i915 driver creates the
* hdmi-lpe-audio platform device. Card creation is deferred until a * hdmi-lpe-audio platform device.
* hot plug event is received
*/ */
static int hdmi_lpe_audio_probe(struct platform_device *pdev) static int hdmi_lpe_audio_probe(struct platform_device *pdev)
{ {
...@@ -2084,8 +2055,7 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev) ...@@ -2084,8 +2055,7 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
/* /*
* hdmi_lpe_audio_remove - stop bridge with i915 * hdmi_lpe_audio_remove - stop bridge with i915
* *
* This function is called when the platform device is destroyed. The sound * This function is called when the platform device is destroyed.
* card should have been removed on hot plug event.
*/ */
static int hdmi_lpe_audio_remove(struct platform_device *pdev) static int hdmi_lpe_audio_remove(struct platform_device *pdev)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment