Commit f69bd104 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: x86: Move stream status into pcm_stream_info

The only remaining field in struct had_stream_data is stream_type that
holds the current stream status.  Such information fits better in
struct pcm_stream_info, so move it as a boolean "running" field to be
clearer.

This allows us to get rid or had_stream_data definition and
references.

Also, the superfluous status check get removed in a couple of places
where we can call PCM helpers in anyway.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 182cdf23
...@@ -967,11 +967,9 @@ static int snd_intelhad_open(struct snd_pcm_substream *substream) ...@@ -967,11 +967,9 @@ static int snd_intelhad_open(struct snd_pcm_substream *substream)
{ {
struct snd_intelhad *intelhaddata; struct snd_intelhad *intelhaddata;
struct snd_pcm_runtime *runtime; struct snd_pcm_runtime *runtime;
struct had_stream_data *had_stream;
int retval; int retval;
intelhaddata = snd_pcm_substream_chip(substream); intelhaddata = snd_pcm_substream_chip(substream);
had_stream = &intelhaddata->stream_data;
runtime = substream->runtime; runtime = substream->runtime;
intelhaddata->underrun_count = 0; intelhaddata->underrun_count = 0;
...@@ -1122,10 +1120,8 @@ static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream, ...@@ -1122,10 +1120,8 @@ static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream,
{ {
int retval = 0; int retval = 0;
struct snd_intelhad *intelhaddata; struct snd_intelhad *intelhaddata;
struct had_stream_data *had_stream;
intelhaddata = snd_pcm_substream_chip(substream); intelhaddata = snd_pcm_substream_chip(substream);
had_stream = &intelhaddata->stream_data;
switch (cmd) { switch (cmd) {
case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_START:
...@@ -1139,7 +1135,7 @@ static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream, ...@@ -1139,7 +1135,7 @@ static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream,
break; break;
} }
had_stream->stream_type = HAD_RUNNING_STREAM; intelhaddata->stream_info.running = true;
/* Enable Audio */ /* Enable Audio */
snd_intelhad_enable_audio_int(intelhaddata, true); snd_intelhad_enable_audio_int(intelhaddata, true);
...@@ -1154,7 +1150,7 @@ static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream, ...@@ -1154,7 +1150,7 @@ static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream,
/* Stop reporting BUFFER_DONE/UNDERRUN to above layers */ /* Stop reporting BUFFER_DONE/UNDERRUN to above layers */
had_stream->stream_type = HAD_INIT; intelhaddata->stream_info.running = false;
spin_unlock(&intelhaddata->had_spinlock); spin_unlock(&intelhaddata->had_spinlock);
/* Disable Audio */ /* Disable Audio */
snd_intelhad_enable_audio_int(intelhaddata, false); snd_intelhad_enable_audio_int(intelhaddata, false);
...@@ -1184,11 +1180,9 @@ static int snd_intelhad_pcm_prepare(struct snd_pcm_substream *substream) ...@@ -1184,11 +1180,9 @@ static int snd_intelhad_pcm_prepare(struct snd_pcm_substream *substream)
u32 link_rate = 0; u32 link_rate = 0;
struct snd_intelhad *intelhaddata; struct snd_intelhad *intelhaddata;
struct snd_pcm_runtime *runtime; struct snd_pcm_runtime *runtime;
struct had_stream_data *had_stream;
intelhaddata = snd_pcm_substream_chip(substream); intelhaddata = snd_pcm_substream_chip(substream);
runtime = substream->runtime; runtime = substream->runtime;
had_stream = &intelhaddata->stream_data;
if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) { if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) {
dev_dbg(intelhaddata->dev, "%s: HDMI cable plugged-out\n", dev_dbg(intelhaddata->dev, "%s: HDMI cable plugged-out\n",
...@@ -1364,9 +1358,6 @@ static inline int had_chk_intrmiss(struct snd_intelhad *intelhaddata, ...@@ -1364,9 +1358,6 @@ static inline int had_chk_intrmiss(struct snd_intelhad *intelhaddata,
int i, intr_count = 0; int i, intr_count = 0;
enum intel_had_aud_buf_type buff_done; enum intel_had_aud_buf_type buff_done;
u32 buf_size, buf_addr; u32 buf_size, buf_addr;
struct had_stream_data *had_stream;
had_stream = &intelhaddata->stream_data;
buff_done = buf_id; buff_done = buf_id;
...@@ -1409,11 +1400,9 @@ static int had_process_buffer_done(struct snd_intelhad *intelhaddata) ...@@ -1409,11 +1400,9 @@ static int had_process_buffer_done(struct snd_intelhad *intelhaddata)
struct pcm_stream_info *stream; struct pcm_stream_info *stream;
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
u32 buf_size; u32 buf_size;
struct had_stream_data *had_stream;
int intr_count; int intr_count;
unsigned long flags; unsigned long flags;
had_stream = &intelhaddata->stream_data;
stream = &intelhaddata->stream_info; stream = &intelhaddata->stream_info;
intr_count = 1; intr_count = 1;
...@@ -1435,7 +1424,7 @@ static int had_process_buffer_done(struct snd_intelhad *intelhaddata) ...@@ -1435,7 +1424,7 @@ static int had_process_buffer_done(struct snd_intelhad *intelhaddata)
*/ */
/* Check for any intr_miss in case of active playback */ /* Check for any intr_miss in case of active playback */
if (had_stream->stream_type == HAD_RUNNING_STREAM) { if (stream->running) {
intr_count = had_chk_intrmiss(intelhaddata, buf_id); intr_count = had_chk_intrmiss(intelhaddata, buf_id);
if (!intr_count || (intr_count > 3)) { if (!intr_count || (intr_count > 3)) {
spin_unlock_irqrestore(&intelhaddata->had_spinlock, spin_unlock_irqrestore(&intelhaddata->had_spinlock,
...@@ -1450,7 +1439,7 @@ static int had_process_buffer_done(struct snd_intelhad *intelhaddata) ...@@ -1450,7 +1439,7 @@ static int had_process_buffer_done(struct snd_intelhad *intelhaddata)
intelhaddata->buf_info[buf_id].is_valid = true; intelhaddata->buf_info[buf_id].is_valid = true;
if (intelhaddata->valid_buf_cnt-1 == buf_id) { if (intelhaddata->valid_buf_cnt-1 == buf_id) {
if (had_stream->stream_type >= HAD_RUNNING_STREAM) if (stream->running)
intelhaddata->curr_buf = HAD_BUF_TYPE_A; intelhaddata->curr_buf = HAD_BUF_TYPE_A;
} else } else
intelhaddata->curr_buf = buf_id + 1; intelhaddata->curr_buf = buf_id + 1;
...@@ -1496,27 +1485,23 @@ static int had_process_buffer_underrun(struct snd_intelhad *intelhaddata) ...@@ -1496,27 +1485,23 @@ static int had_process_buffer_underrun(struct snd_intelhad *intelhaddata)
{ {
enum intel_had_aud_buf_type buf_id; enum intel_had_aud_buf_type buf_id;
struct pcm_stream_info *stream; struct pcm_stream_info *stream;
struct had_stream_data *had_stream;
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
enum had_status_stream stream_type;
unsigned long flags; unsigned long flags;
int drv_status; int drv_status;
had_stream = &intelhaddata->stream_data;
stream = &intelhaddata->stream_info; stream = &intelhaddata->stream_info;
spin_lock_irqsave(&intelhaddata->had_spinlock, flags); spin_lock_irqsave(&intelhaddata->had_spinlock, flags);
buf_id = intelhaddata->curr_buf; buf_id = intelhaddata->curr_buf;
stream_type = had_stream->stream_type;
intelhaddata->buff_done = buf_id; intelhaddata->buff_done = buf_id;
drv_status = intelhaddata->drv_status; drv_status = intelhaddata->drv_status;
if (stream_type == HAD_RUNNING_STREAM) if (stream->running)
intelhaddata->curr_buf = HAD_BUF_TYPE_A; intelhaddata->curr_buf = HAD_BUF_TYPE_A;
spin_unlock_irqrestore(&intelhaddata->had_spinlock, flags); spin_unlock_irqrestore(&intelhaddata->had_spinlock, flags);
dev_dbg(intelhaddata->dev, "Enter:%s buf_id=%d, stream_type=%d\n", dev_dbg(intelhaddata->dev, "Enter:%s buf_id=%d, stream_running=%d\n",
__func__, buf_id, stream_type); __func__, buf_id, stream->running);
snd_intelhad_handle_underrun(intelhaddata); snd_intelhad_handle_underrun(intelhaddata);
...@@ -1526,13 +1511,11 @@ static int had_process_buffer_underrun(struct snd_intelhad *intelhaddata) ...@@ -1526,13 +1511,11 @@ static int had_process_buffer_underrun(struct snd_intelhad *intelhaddata)
return 0; return 0;
} }
if (stream_type == HAD_RUNNING_STREAM) { /* Report UNDERRUN error to above layers */
/* Report UNDERRUN error to above layers */ substream = had_substream_get(intelhaddata);
substream = had_substream_get(intelhaddata); if (substream) {
if (substream) { snd_pcm_stop_xrun(substream);
snd_pcm_stop_xrun(substream); had_substream_put(intelhaddata);
had_substream_put(intelhaddata);
}
} }
return 0; return 0;
...@@ -1543,9 +1526,6 @@ static void had_process_hot_plug(struct snd_intelhad *intelhaddata) ...@@ -1543,9 +1526,6 @@ static void had_process_hot_plug(struct snd_intelhad *intelhaddata)
{ {
enum intel_had_aud_buf_type buf_id; enum intel_had_aud_buf_type buf_id;
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
struct had_stream_data *had_stream;
had_stream = &intelhaddata->stream_data;
spin_lock_irq(&intelhaddata->had_spinlock); spin_lock_irq(&intelhaddata->had_spinlock);
if (intelhaddata->drv_status == HAD_DRV_CONNECTED) { if (intelhaddata->drv_status == HAD_DRV_CONNECTED) {
...@@ -1582,10 +1562,8 @@ static void had_process_hot_plug(struct snd_intelhad *intelhaddata) ...@@ -1582,10 +1562,8 @@ static void had_process_hot_plug(struct snd_intelhad *intelhaddata)
static void had_process_hot_unplug(struct snd_intelhad *intelhaddata) static void had_process_hot_unplug(struct snd_intelhad *intelhaddata)
{ {
enum intel_had_aud_buf_type buf_id; enum intel_had_aud_buf_type buf_id;
struct had_stream_data *had_stream;
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
had_stream = &intelhaddata->stream_data;
buf_id = intelhaddata->curr_buf; buf_id = intelhaddata->curr_buf;
substream = had_substream_get(intelhaddata); substream = had_substream_get(intelhaddata);
...@@ -1607,7 +1585,6 @@ static void had_process_hot_unplug(struct snd_intelhad *intelhaddata) ...@@ -1607,7 +1585,6 @@ static void had_process_hot_unplug(struct snd_intelhad *intelhaddata)
dev_dbg(intelhaddata->dev, dev_dbg(intelhaddata->dev,
"%s @ %d:DEBUG PLUG/UNPLUG : HAD_DRV_DISCONNECTED\n", "%s @ %d:DEBUG PLUG/UNPLUG : HAD_DRV_DISCONNECTED\n",
__func__, __LINE__); __func__, __LINE__);
had_stream->stream_type = HAD_INIT;
spin_unlock_irq(&intelhaddata->had_spinlock); spin_unlock_irq(&intelhaddata->had_spinlock);
/* Report to above ALSA layer */ /* Report to above ALSA layer */
...@@ -1775,8 +1752,7 @@ static void had_audio_wq(struct work_struct *work) ...@@ -1775,8 +1752,7 @@ static void had_audio_wq(struct work_struct *work)
had_process_hot_plug(ctx); had_process_hot_plug(ctx);
/* Process mode change if stream is active */ /* Process mode change if stream is active */
if (ctx->stream_data.stream_type == HAD_RUNNING_STREAM) hdmi_audio_mode_change(ctx);
hdmi_audio_mode_change(ctx);
} }
mutex_unlock(&ctx->mutex); mutex_unlock(&ctx->mutex);
pm_runtime_put(ctx->dev); pm_runtime_put(ctx->dev);
......
...@@ -76,6 +76,7 @@ struct pcm_stream_info { ...@@ -76,6 +76,7 @@ struct pcm_stream_info {
u64 buffer_rendered; u64 buffer_rendered;
u32 ring_buf_size; u32 ring_buf_size;
int substream_refcount; int substream_refcount;
bool running;
}; };
struct ring_buf_info { struct ring_buf_info {
...@@ -84,10 +85,6 @@ struct ring_buf_info { ...@@ -84,10 +85,6 @@ struct ring_buf_info {
u8 is_valid; u8 is_valid;
}; };
struct had_stream_data {
enum had_status_stream stream_type;
};
/** /**
* struct snd_intelhad - intelhad driver structure * struct snd_intelhad - intelhad driver structure
* *
...@@ -115,7 +112,6 @@ struct snd_intelhad { ...@@ -115,7 +112,6 @@ struct snd_intelhad {
enum intel_had_aud_buf_type curr_buf; enum intel_had_aud_buf_type curr_buf;
int valid_buf_cnt; int valid_buf_cnt;
unsigned int aes_bits; unsigned int aes_bits;
struct had_stream_data stream_data;
spinlock_t had_spinlock; spinlock_t had_spinlock;
enum intel_had_aud_buf_type buff_done; enum intel_had_aud_buf_type buff_done;
struct device *dev; struct device *dev;
......
...@@ -223,14 +223,6 @@ union otm_hdmi_eld_t { ...@@ -223,14 +223,6 @@ union otm_hdmi_eld_t {
} __packed; } __packed;
}; };
/**
* enum had_status_stream - HAD stream states
*/
enum had_status_stream {
HAD_INIT = 0,
HAD_RUNNING_STREAM,
};
enum had_drv_status { enum had_drv_status {
HAD_DRV_CONNECTED, HAD_DRV_CONNECTED,
HAD_DRV_RUNNING, HAD_DRV_RUNNING,
......
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