diff options
author | Takashi Iwai <tiwai@suse.de> | 2017-02-02 11:46:49 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2017-02-03 11:38:02 -0500 |
commit | 91b0cb0cc07bcb5114df2897531f4ea41c148c8e (patch) | |
tree | 908887701b13c5556b6d597f8c35299b43ec54ea | |
parent | 73997b050c995f34f3617d344f1e767d15b2477d (diff) |
ALSA: x86: Rename drv_status to connected
After the rewrite of the runtime PM code, we have only two driver
status: CONNECTED and DISCONNECTED. So it's clearer to use a boolean
flag, and name it easier one, "connected".
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/x86/intel_hdmi_audio.c | 40 | ||||
-rw-r--r-- | sound/x86/intel_hdmi_audio.h | 4 | ||||
-rw-r--r-- | sound/x86/intel_hdmi_lpe_audio.h | 8 |
3 files changed, 22 insertions, 30 deletions
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c index f032610d1287..c83f02c2593e 100644 --- a/sound/x86/intel_hdmi_audio.c +++ b/sound/x86/intel_hdmi_audio.c | |||
@@ -202,7 +202,7 @@ mid_hdmi_audio_write(struct snd_intelhad *ctx, u32 reg, u32 val) | |||
202 | static int had_read_register(struct snd_intelhad *intelhaddata, | 202 | static int had_read_register(struct snd_intelhad *intelhaddata, |
203 | u32 offset, u32 *data) | 203 | u32 offset, u32 *data) |
204 | { | 204 | { |
205 | if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) | 205 | if (!intelhaddata->connected) |
206 | return -ENODEV; | 206 | return -ENODEV; |
207 | 207 | ||
208 | mid_hdmi_audio_read(intelhaddata, offset, data); | 208 | mid_hdmi_audio_read(intelhaddata, offset, data); |
@@ -221,7 +221,7 @@ static void fixup_dp_config(struct snd_intelhad *intelhaddata, | |||
221 | static int had_write_register(struct snd_intelhad *intelhaddata, | 221 | static int had_write_register(struct snd_intelhad *intelhaddata, |
222 | u32 offset, u32 data) | 222 | u32 offset, u32 data) |
223 | { | 223 | { |
224 | if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) | 224 | if (!intelhaddata->connected) |
225 | return -ENODEV; | 225 | return -ENODEV; |
226 | 226 | ||
227 | fixup_dp_config(intelhaddata, offset, &data); | 227 | fixup_dp_config(intelhaddata, offset, &data); |
@@ -234,7 +234,7 @@ static int had_read_modify(struct snd_intelhad *intelhaddata, u32 offset, | |||
234 | { | 234 | { |
235 | u32 val_tmp; | 235 | u32 val_tmp; |
236 | 236 | ||
237 | if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) | 237 | if (!intelhaddata->connected) |
238 | return -ENODEV; | 238 | return -ENODEV; |
239 | 239 | ||
240 | mid_hdmi_audio_read(intelhaddata, offset, &val_tmp); | 240 | mid_hdmi_audio_read(intelhaddata, offset, &val_tmp); |
@@ -556,7 +556,7 @@ static int had_chmap_ctl_info(struct snd_kcontrol *kcontrol, | |||
556 | struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); | 556 | struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); |
557 | struct snd_intelhad *intelhaddata = info->private_data; | 557 | struct snd_intelhad *intelhaddata = info->private_data; |
558 | 558 | ||
559 | if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) | 559 | if (!intelhaddata->connected) |
560 | return -ENODEV; | 560 | return -ENODEV; |
561 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 561 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
562 | uinfo->count = HAD_MAX_CHANNEL; | 562 | uinfo->count = HAD_MAX_CHANNEL; |
@@ -573,7 +573,7 @@ static int had_chmap_ctl_get(struct snd_kcontrol *kcontrol, | |||
573 | int i; | 573 | int i; |
574 | const struct snd_pcm_chmap_elem *chmap; | 574 | const struct snd_pcm_chmap_elem *chmap; |
575 | 575 | ||
576 | if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) | 576 | if (!intelhaddata->connected) |
577 | return -ENODEV; | 577 | return -ENODEV; |
578 | 578 | ||
579 | mutex_lock(&intelhaddata->mutex); | 579 | mutex_lock(&intelhaddata->mutex); |
@@ -968,7 +968,7 @@ static int snd_intelhad_open(struct snd_pcm_substream *substream) | |||
968 | 968 | ||
969 | pm_runtime_get_sync(intelhaddata->dev); | 969 | pm_runtime_get_sync(intelhaddata->dev); |
970 | 970 | ||
971 | if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) { | 971 | if (!intelhaddata->connected) { |
972 | dev_dbg(intelhaddata->dev, "%s: HDMI cable plugged-out\n", | 972 | dev_dbg(intelhaddata->dev, "%s: HDMI cable plugged-out\n", |
973 | __func__); | 973 | __func__); |
974 | retval = -ENODEV; | 974 | retval = -ENODEV; |
@@ -1098,7 +1098,7 @@ static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream, | |||
1098 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 1098 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
1099 | case SNDRV_PCM_TRIGGER_RESUME: | 1099 | case SNDRV_PCM_TRIGGER_RESUME: |
1100 | /* Disable local INTRs till register prgmng is done */ | 1100 | /* Disable local INTRs till register prgmng is done */ |
1101 | if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) { | 1101 | if (!intelhaddata->connected) { |
1102 | dev_dbg(intelhaddata->dev, | 1102 | dev_dbg(intelhaddata->dev, |
1103 | "_START: HDMI cable plugged-out\n"); | 1103 | "_START: HDMI cable plugged-out\n"); |
1104 | retval = -ENODEV; | 1104 | retval = -ENODEV; |
@@ -1150,7 +1150,7 @@ static int snd_intelhad_pcm_prepare(struct snd_pcm_substream *substream) | |||
1150 | intelhaddata = snd_pcm_substream_chip(substream); | 1150 | intelhaddata = snd_pcm_substream_chip(substream); |
1151 | runtime = substream->runtime; | 1151 | runtime = substream->runtime; |
1152 | 1152 | ||
1153 | if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) { | 1153 | if (!intelhaddata->connected) { |
1154 | dev_dbg(intelhaddata->dev, "%s: HDMI cable plugged-out\n", | 1154 | dev_dbg(intelhaddata->dev, "%s: HDMI cable plugged-out\n", |
1155 | __func__); | 1155 | __func__); |
1156 | retval = -ENODEV; | 1156 | retval = -ENODEV; |
@@ -1219,7 +1219,7 @@ snd_intelhad_pcm_pointer(struct snd_pcm_substream *substream) | |||
1219 | 1219 | ||
1220 | intelhaddata = snd_pcm_substream_chip(substream); | 1220 | intelhaddata = snd_pcm_substream_chip(substream); |
1221 | 1221 | ||
1222 | if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) | 1222 | if (!intelhaddata->connected) |
1223 | return SNDRV_PCM_POS_XRUN; | 1223 | return SNDRV_PCM_POS_XRUN; |
1224 | 1224 | ||
1225 | /* Use a hw register to calculate sub-period position reports. | 1225 | /* Use a hw register to calculate sub-period position reports. |
@@ -1380,7 +1380,7 @@ static int had_process_buffer_done(struct snd_intelhad *intelhaddata) | |||
1380 | intr_count = 1; | 1380 | intr_count = 1; |
1381 | 1381 | ||
1382 | spin_lock_irqsave(&intelhaddata->had_spinlock, flags); | 1382 | spin_lock_irqsave(&intelhaddata->had_spinlock, flags); |
1383 | if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) { | 1383 | if (!intelhaddata->connected) { |
1384 | spin_unlock_irqrestore(&intelhaddata->had_spinlock, flags); | 1384 | spin_unlock_irqrestore(&intelhaddata->had_spinlock, flags); |
1385 | dev_dbg(intelhaddata->dev, | 1385 | dev_dbg(intelhaddata->dev, |
1386 | "%s:Device already disconnected\n", __func__); | 1386 | "%s:Device already disconnected\n", __func__); |
@@ -1419,7 +1419,7 @@ static int had_process_buffer_done(struct snd_intelhad *intelhaddata) | |||
1419 | 1419 | ||
1420 | spin_unlock_irqrestore(&intelhaddata->had_spinlock, flags); | 1420 | spin_unlock_irqrestore(&intelhaddata->had_spinlock, flags); |
1421 | 1421 | ||
1422 | if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) { | 1422 | if (!intelhaddata->connected) { |
1423 | dev_dbg(intelhaddata->dev, "HDMI cable plugged-out\n"); | 1423 | dev_dbg(intelhaddata->dev, "HDMI cable plugged-out\n"); |
1424 | return 0; | 1424 | return 0; |
1425 | } | 1425 | } |
@@ -1460,14 +1460,14 @@ static int had_process_buffer_underrun(struct snd_intelhad *intelhaddata) | |||
1460 | struct pcm_stream_info *stream; | 1460 | struct pcm_stream_info *stream; |
1461 | struct snd_pcm_substream *substream; | 1461 | struct snd_pcm_substream *substream; |
1462 | unsigned long flags; | 1462 | unsigned long flags; |
1463 | int drv_status; | 1463 | int connected; |
1464 | 1464 | ||
1465 | stream = &intelhaddata->stream_info; | 1465 | stream = &intelhaddata->stream_info; |
1466 | 1466 | ||
1467 | spin_lock_irqsave(&intelhaddata->had_spinlock, flags); | 1467 | spin_lock_irqsave(&intelhaddata->had_spinlock, flags); |
1468 | buf_id = intelhaddata->curr_buf; | 1468 | buf_id = intelhaddata->curr_buf; |
1469 | intelhaddata->buff_done = buf_id; | 1469 | intelhaddata->buff_done = buf_id; |
1470 | drv_status = intelhaddata->drv_status; | 1470 | connected = intelhaddata->connected; |
1471 | if (stream->running) | 1471 | if (stream->running) |
1472 | intelhaddata->curr_buf = HAD_BUF_TYPE_A; | 1472 | intelhaddata->curr_buf = HAD_BUF_TYPE_A; |
1473 | 1473 | ||
@@ -1478,7 +1478,7 @@ static int had_process_buffer_underrun(struct snd_intelhad *intelhaddata) | |||
1478 | 1478 | ||
1479 | snd_intelhad_handle_underrun(intelhaddata); | 1479 | snd_intelhad_handle_underrun(intelhaddata); |
1480 | 1480 | ||
1481 | if (drv_status == HAD_DRV_DISCONNECTED) { | 1481 | if (!connected) { |
1482 | dev_dbg(intelhaddata->dev, | 1482 | dev_dbg(intelhaddata->dev, |
1483 | "%s:Device already disconnected\n", __func__); | 1483 | "%s:Device already disconnected\n", __func__); |
1484 | return 0; | 1484 | return 0; |
@@ -1501,7 +1501,7 @@ static void had_process_hot_plug(struct snd_intelhad *intelhaddata) | |||
1501 | struct snd_pcm_substream *substream; | 1501 | struct snd_pcm_substream *substream; |
1502 | 1502 | ||
1503 | spin_lock_irq(&intelhaddata->had_spinlock); | 1503 | spin_lock_irq(&intelhaddata->had_spinlock); |
1504 | if (intelhaddata->drv_status == HAD_DRV_CONNECTED) { | 1504 | if (intelhaddata->connected) { |
1505 | dev_dbg(intelhaddata->dev, "Device already connected\n"); | 1505 | dev_dbg(intelhaddata->dev, "Device already connected\n"); |
1506 | spin_unlock_irq(&intelhaddata->had_spinlock); | 1506 | spin_unlock_irq(&intelhaddata->had_spinlock); |
1507 | return; | 1507 | return; |
@@ -1509,7 +1509,7 @@ static void had_process_hot_plug(struct snd_intelhad *intelhaddata) | |||
1509 | 1509 | ||
1510 | buf_id = intelhaddata->curr_buf; | 1510 | buf_id = intelhaddata->curr_buf; |
1511 | intelhaddata->buff_done = buf_id; | 1511 | intelhaddata->buff_done = buf_id; |
1512 | intelhaddata->drv_status = HAD_DRV_CONNECTED; | 1512 | intelhaddata->connected = true; |
1513 | dev_dbg(intelhaddata->dev, | 1513 | dev_dbg(intelhaddata->dev, |
1514 | "%s @ %d:DEBUG PLUG/UNPLUG : HAD_DRV_CONNECTED\n", | 1514 | "%s @ %d:DEBUG PLUG/UNPLUG : HAD_DRV_CONNECTED\n", |
1515 | __func__, __LINE__); | 1515 | __func__, __LINE__); |
@@ -1543,7 +1543,7 @@ static void had_process_hot_unplug(struct snd_intelhad *intelhaddata) | |||
1543 | 1543 | ||
1544 | spin_lock_irq(&intelhaddata->had_spinlock); | 1544 | spin_lock_irq(&intelhaddata->had_spinlock); |
1545 | 1545 | ||
1546 | if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) { | 1546 | if (!intelhaddata->connected) { |
1547 | dev_dbg(intelhaddata->dev, "Device already disconnected\n"); | 1547 | dev_dbg(intelhaddata->dev, "Device already disconnected\n"); |
1548 | spin_unlock_irq(&intelhaddata->had_spinlock); | 1548 | spin_unlock_irq(&intelhaddata->had_spinlock); |
1549 | goto out; | 1549 | goto out; |
@@ -1554,7 +1554,7 @@ static void had_process_hot_unplug(struct snd_intelhad *intelhaddata) | |||
1554 | snd_intelhad_enable_audio_int(intelhaddata, false); | 1554 | snd_intelhad_enable_audio_int(intelhaddata, false); |
1555 | snd_intelhad_enable_audio(substream, intelhaddata, false); | 1555 | snd_intelhad_enable_audio(substream, intelhaddata, false); |
1556 | 1556 | ||
1557 | intelhaddata->drv_status = HAD_DRV_DISCONNECTED; | 1557 | intelhaddata->connected = false; |
1558 | dev_dbg(intelhaddata->dev, | 1558 | dev_dbg(intelhaddata->dev, |
1559 | "%s @ %d:DEBUG PLUG/UNPLUG : HAD_DRV_DISCONNECTED\n", | 1559 | "%s @ %d:DEBUG PLUG/UNPLUG : HAD_DRV_DISCONNECTED\n", |
1560 | __func__, __LINE__); | 1560 | __func__, __LINE__); |
@@ -1855,7 +1855,7 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev) | |||
1855 | ctx = card->private_data; | 1855 | ctx = card->private_data; |
1856 | spin_lock_init(&ctx->had_spinlock); | 1856 | spin_lock_init(&ctx->had_spinlock); |
1857 | mutex_init(&ctx->mutex); | 1857 | mutex_init(&ctx->mutex); |
1858 | ctx->drv_status = HAD_DRV_DISCONNECTED; | 1858 | ctx->connected = false; |
1859 | ctx->dev = &pdev->dev; | 1859 | ctx->dev = &pdev->dev; |
1860 | ctx->card = card; | 1860 | ctx->card = card; |
1861 | ctx->aes_bits = SNDRV_PCM_DEFAULT_CON_SPDIF; | 1861 | ctx->aes_bits = SNDRV_PCM_DEFAULT_CON_SPDIF; |
@@ -1960,7 +1960,7 @@ static int hdmi_lpe_audio_remove(struct platform_device *pdev) | |||
1960 | { | 1960 | { |
1961 | struct snd_intelhad *ctx = platform_get_drvdata(pdev); | 1961 | struct snd_intelhad *ctx = platform_get_drvdata(pdev); |
1962 | 1962 | ||
1963 | if (ctx->drv_status != HAD_DRV_DISCONNECTED) | 1963 | if (ctx->connected) |
1964 | snd_intelhad_enable_audio_int(ctx, false); | 1964 | snd_intelhad_enable_audio_int(ctx, false); |
1965 | snd_card_free(ctx->card); | 1965 | snd_card_free(ctx->card); |
1966 | return 0; | 1966 | return 0; |
diff --git a/sound/x86/intel_hdmi_audio.h b/sound/x86/intel_hdmi_audio.h index dea51fcfc07f..9f713a8a88bc 100644 --- a/sound/x86/intel_hdmi_audio.h +++ b/sound/x86/intel_hdmi_audio.h | |||
@@ -80,7 +80,7 @@ struct ring_buf_info { | |||
80 | * struct snd_intelhad - intelhad driver structure | 80 | * struct snd_intelhad - intelhad driver structure |
81 | * | 81 | * |
82 | * @card: ptr to hold card details | 82 | * @card: ptr to hold card details |
83 | * @drv_status: driver status | 83 | * @connected: the monitor connection status |
84 | * @buf_info: ring buffer info | 84 | * @buf_info: ring buffer info |
85 | * @stream_info: stream information | 85 | * @stream_info: stream information |
86 | * @eld: holds ELD info | 86 | * @eld: holds ELD info |
@@ -95,7 +95,7 @@ struct ring_buf_info { | |||
95 | */ | 95 | */ |
96 | struct snd_intelhad { | 96 | struct snd_intelhad { |
97 | struct snd_card *card; | 97 | struct snd_card *card; |
98 | enum had_drv_status drv_status; | 98 | bool connected; |
99 | struct ring_buf_info buf_info[HAD_NUM_OF_RING_BUFS]; | 99 | struct ring_buf_info buf_info[HAD_NUM_OF_RING_BUFS]; |
100 | struct pcm_stream_info stream_info; | 100 | struct pcm_stream_info stream_info; |
101 | unsigned char eld[HDMI_MAX_ELD_BYTES]; | 101 | unsigned char eld[HDMI_MAX_ELD_BYTES]; |
diff --git a/sound/x86/intel_hdmi_lpe_audio.h b/sound/x86/intel_hdmi_lpe_audio.h index 5a5adb7f0cde..be9783910a3a 100644 --- a/sound/x86/intel_hdmi_lpe_audio.h +++ b/sound/x86/intel_hdmi_lpe_audio.h | |||
@@ -82,14 +82,6 @@ | |||
82 | /* Naud Value */ | 82 | /* Naud Value */ |
83 | #define DP_NAUD_VAL 32768 | 83 | #define DP_NAUD_VAL 32768 |
84 | 84 | ||
85 | enum had_drv_status { | ||
86 | HAD_DRV_CONNECTED, | ||
87 | HAD_DRV_RUNNING, | ||
88 | HAD_DRV_DISCONNECTED, | ||
89 | HAD_DRV_SUSPENDED, | ||
90 | HAD_DRV_ERR, | ||
91 | }; | ||
92 | |||
93 | /* enum intel_had_aud_buf_type - HDMI controller ring buffer types */ | 85 | /* enum intel_had_aud_buf_type - HDMI controller ring buffer types */ |
94 | enum intel_had_aud_buf_type { | 86 | enum intel_had_aud_buf_type { |
95 | HAD_BUF_TYPE_A = 0, | 87 | HAD_BUF_TYPE_A = 0, |