Commit da864809 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: x86: Flatten two abstraction layers

This is the final stage for a big clean-up series.  Here we flatten
the two layers into one.  Formerly, the implementation was split to
HDMI "shell" that talks with the platform device, and HDMI audio part
that communicates via caps and other event handlers.  All these would
be good if there were multiple instantiations or if there were data
protection.  But neither are true in our case.  That said, it'll be
easier to have a flat driver structure in the end.

In this patch, the former struct hdmi_lpe_audio_ctx is forged into the
existing struct snd_intelhad.  The latter has already a few members
that are basically the copy from the former.  Only a few new members
for the lowlevel I/O are added by this change.

Then, the had_get_caps() and had_set_caps() are simply replaced with
the direct calls to copy the data in the struct fields.  Also, the
had_event_handler() calls are replaced with the direct call for each
event as well.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent eeb756c5
snd-hdmi-lpe-audio-objs += \
intel_hdmi_audio.o \
intel_hdmi_audio_if.o \
intel_hdmi_lpe_audio.o
intel_hdmi_audio_if.o
obj-$(CONFIG_HDMI_LPE_AUDIO) += snd-hdmi-lpe-audio.o
This diff is collapsed.
......@@ -108,7 +108,7 @@ struct had_stream_data {
* @drv_status: driver status
* @buf_info: ring buffer info
* @stream_info: stream information
* @eeld: holds EELD info
* @eld: holds ELD info
* @curr_buf: pointer to hold current active ring buf
* @valid_buf_cnt: ring buffer count for stream
* @had_spinlock: driver lock
......@@ -127,7 +127,7 @@ struct snd_intelhad {
enum had_drv_status drv_status;
struct ring_buf_info buf_info[HAD_NUM_OF_RING_BUFS];
struct pcm_stream_info stream_info;
union otm_hdmi_eld_t eeld;
union otm_hdmi_eld_t eld;
bool dp_output;
enum intel_had_aud_buf_type curr_buf;
int valid_buf_cnt;
......@@ -142,15 +142,27 @@ struct snd_intelhad {
unsigned int *audio_reg_base;
unsigned int audio_cfg_offset;
int underrun_count;
enum hdmi_connector_status state;
int tmds_clock_speed;
int link_rate;
/* internal stuff */
int irq;
void __iomem *mmio_start;
unsigned int had_config_offset;
int hdmi_audio_interrupt_mask;
struct work_struct hdmi_audio_wq;
};
int had_event_handler(enum had_event_type event_type, void *data);
int hdmi_audio_suspend(void *drv_data);
int hdmi_audio_resume(void *drv_data);
int hdmi_audio_mode_change(struct snd_pcm_substream *substream);
int hdmi_lpe_audio_suspend(struct platform_device *pdev, pm_message_t state);
int hdmi_lpe_audio_resume(struct platform_device *pdev);
extern struct snd_pcm_ops snd_intelhad_playback_ops;
int had_process_buffer_done(struct snd_intelhad *intelhaddata);
int had_process_buffer_underrun(struct snd_intelhad *intelhaddata);
int had_process_hot_plug(struct snd_intelhad *intelhaddata);
int had_process_hot_unplug(struct snd_intelhad *intelhaddata);
int snd_intelhad_init_audio_ctrl(struct snd_pcm_substream *substream,
struct snd_intelhad *intelhaddata,
int flag_silence);
......@@ -160,15 +172,12 @@ int snd_intelhad_invd_buffer(int start, int end);
int snd_intelhad_read_len(struct snd_intelhad *intelhaddata);
void had_build_channel_allocation_map(struct snd_intelhad *intelhaddata);
void snd_intelhad_enable_audio(struct snd_pcm_substream *substream, u8 enable);
void snd_intelhad_enable_audio_int(struct snd_intelhad *ctx, bool enable);
void snd_intelhad_enable_audio(struct snd_intelhad *ctx, bool enable);
void snd_intelhad_handle_underrun(struct snd_intelhad *intelhaddata);
/* Register access functions */
int had_get_hwstate(struct snd_intelhad *intelhaddata);
int had_get_caps(struct snd_intelhad *intelhaddata,
enum had_caps_list query_element, void *capabilties);
int had_set_caps(struct snd_intelhad *intelhaddata,
enum had_caps_list set_element, void *capabilties);
int had_read_register(struct snd_intelhad *intelhaddata,
u32 reg_addr, u32 *data);
int had_write_register(struct snd_intelhad *intelhaddata,
......@@ -176,8 +185,4 @@ int had_write_register(struct snd_intelhad *intelhaddata,
int had_read_modify(struct snd_intelhad *intelhaddata,
u32 reg_addr, u32 data, u32 mask);
int hdmi_audio_probe(struct platform_device *devptr,
struct snd_intelhad **had_ret);
int hdmi_audio_remove(struct snd_intelhad *intelhaddata);
#endif /* _INTEL_HDMI_AUDIO_ */
......@@ -33,21 +33,20 @@
#include "intel_hdmi_audio.h"
#include "intel_hdmi_lpe_audio.h"
/**
* hdmi_audio_suspend - power management suspend function
/*
* hdmi_lpe_audio_suspend - power management suspend function
*
*@haddata: pointer to HAD private data
* @pdev: platform device
*
* This function is called by client driver to suspend the
* hdmi audio.
*/
int hdmi_audio_suspend(void *haddata)
int hdmi_lpe_audio_suspend(struct platform_device *pdev, pm_message_t state)
{
int caps, retval = 0;
struct had_stream_data *had_stream;
unsigned long flag_irqs;
struct snd_pcm_substream *substream;
struct snd_intelhad *intelhaddata = (struct snd_intelhad *)haddata;
struct snd_intelhad *intelhaddata = platform_get_drvdata(pdev);
pr_debug("Enter:%s\n", __func__);
......@@ -64,13 +63,13 @@ int hdmi_audio_suspend(void *haddata)
if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) {
spin_unlock_irqrestore(&intelhaddata->had_spinlock, flag_irqs);
pr_debug("had not connected\n");
return retval;
return 0;
}
if (intelhaddata->drv_status == HAD_DRV_SUSPENDED) {
spin_unlock_irqrestore(&intelhaddata->had_spinlock, flag_irqs);
pr_debug("had already suspended\n");
return retval;
return 0;
}
intelhaddata->drv_status = HAD_DRV_SUSPENDED;
......@@ -78,29 +77,22 @@ int hdmi_audio_suspend(void *haddata)
__func__, __LINE__);
spin_unlock_irqrestore(&intelhaddata->had_spinlock, flag_irqs);
/*
* ToDo: Need to disable UNDERRUN interrupts as well
* caps = HDMI_AUDIO_UNDERRUN | HDMI_AUDIO_BUFFER_DONE;
*/
caps = HDMI_AUDIO_BUFFER_DONE;
had_set_caps(intelhaddata, HAD_SET_DISABLE_AUDIO_INT, &caps);
had_set_caps(intelhaddata, HAD_SET_DISABLE_AUDIO, NULL);
snd_intelhad_enable_audio_int(intelhaddata, false);
pr_debug("Exit:%s", __func__);
return retval;
return 0;
}
/**
* hdmi_audio_resume - power management resume function
/*
* hdmi_lpe_audio_resume - power management resume function
*
*@haddata: pointer to HAD private data
*@pdev: platform device
*
* This function is called by client driver to resume the
* hdmi audio.
*/
int hdmi_audio_resume(void *haddata)
int hdmi_lpe_audio_resume(struct platform_device *pdev)
{
int caps, retval = 0;
struct snd_intelhad *intelhaddata = (struct snd_intelhad *)haddata;
struct snd_intelhad *intelhaddata = platform_get_drvdata(pdev);
unsigned long flag_irqs;
pr_debug("Enter:%s\n", __func__);
......@@ -128,15 +120,9 @@ int hdmi_audio_resume(void *haddata)
pr_debug("%s @ %d:DEBUG PLUG/UNPLUG : HAD_DRV_DISCONNECTED\n",
__func__, __LINE__);
spin_unlock_irqrestore(&intelhaddata->had_spinlock, flag_irqs);
/*
* ToDo: Need to enable UNDERRUN interrupts as well
* caps = HDMI_AUDIO_UNDERRUN | HDMI_AUDIO_BUFFER_DONE;
*/
caps = HDMI_AUDIO_BUFFER_DONE;
retval = had_set_caps(intelhaddata, HAD_SET_ENABLE_AUDIO_INT, &caps);
retval = had_set_caps(intelhaddata, HAD_SET_ENABLE_AUDIO, NULL);
snd_intelhad_enable_audio_int(intelhaddata, true);
pr_debug("Exit:%s", __func__);
return retval;
return 0;
}
static inline int had_chk_intrmiss(struct snd_intelhad *intelhaddata,
......@@ -357,7 +343,6 @@ int had_process_hot_plug(struct snd_intelhad *intelhaddata)
int had_process_hot_unplug(struct snd_intelhad *intelhaddata)
{
int caps, retval = 0;
enum intel_had_aud_buf_type buf_id;
struct had_stream_data *had_stream;
unsigned long flag_irqs;
......@@ -372,17 +357,12 @@ int had_process_hot_unplug(struct snd_intelhad *intelhaddata)
if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED) {
pr_debug("Device already disconnected\n");
spin_unlock_irqrestore(&intelhaddata->had_spinlock, flag_irqs);
return retval;
return 0;
} else {
/* Disable Audio */
caps = HDMI_AUDIO_BUFFER_DONE;
retval = had_set_caps(intelhaddata, HAD_SET_DISABLE_AUDIO_INT,
&caps);
retval = had_set_caps(intelhaddata, HAD_SET_DISABLE_AUDIO,
NULL);
snd_intelhad_enable_audio(
intelhaddata->stream_info.had_substream, 0);
snd_intelhad_enable_audio_int(intelhaddata, false);
snd_intelhad_enable_audio(intelhaddata, false);
}
intelhaddata->drv_status = HAD_DRV_DISCONNECTED;
......@@ -405,74 +385,6 @@ int had_process_hot_unplug(struct snd_intelhad *intelhaddata)
intelhaddata->audio_reg_base = NULL;
pr_debug("%s: unlocked -> returned\n", __func__);
return retval;
return 0;
}
/**
* had_event_handler - Call back function to handle events
*
* @event_type: Event type to handle
* @data: data related to the event_type
*
* This function is invoked to handle HDMI events from client driver.
*/
int had_event_handler(enum had_event_type event_type, void *data)
{
int retval = 0;
struct snd_intelhad *intelhaddata = data;
enum intel_had_aud_buf_type buf_id;
struct snd_pcm_substream *substream;
struct had_stream_data *had_stream;
unsigned long flag_irqs;
buf_id = intelhaddata->curr_buf;
had_stream = &intelhaddata->stream_data;
/* Switching to a function can drop atomicity even in INTR context.
* Thus, a big lock is acquired to maintain atomicity.
* This can be optimized later.
* Currently, only buffer_done/_underrun executes in INTR context.
* Also, locking is implemented separately to avoid real contention
* of data(struct intelhaddata) between IRQ/SOFT_IRQ/PROCESS context.
*/
substream = intelhaddata->stream_info.had_substream;
switch (event_type) {
case HAD_EVENT_AUDIO_BUFFER_DONE:
retval = had_process_buffer_done(intelhaddata);
break;
case HAD_EVENT_AUDIO_BUFFER_UNDERRUN:
retval = had_process_buffer_underrun(intelhaddata);
break;
case HAD_EVENT_HOT_PLUG:
retval = had_process_hot_plug(intelhaddata);
break;
case HAD_EVENT_HOT_UNPLUG:
retval = had_process_hot_unplug(intelhaddata);
break;
case HAD_EVENT_MODE_CHANGING:
pr_debug(" called _event_handler with _MODE_CHANGE event\n");
/* Process only if stream is active & cable Plugged-in */
spin_lock_irqsave(&intelhaddata->had_spinlock, flag_irqs);
if (intelhaddata->drv_status >= HAD_DRV_DISCONNECTED) {
spin_unlock_irqrestore(&intelhaddata->had_spinlock,
flag_irqs);
break;
}
spin_unlock_irqrestore(&intelhaddata->had_spinlock, flag_irqs);
if ((had_stream->stream_type == HAD_RUNNING_STREAM)
&& substream)
retval = hdmi_audio_mode_change(substream);
break;
default:
pr_debug("error un-handled event !!\n");
retval = -EINVAL;
break;
}
return retval;
}
This diff is collapsed.
......@@ -27,12 +27,11 @@
#include <sound/initval.h>
#include <linux/version.h>
#include <linux/pm_runtime.h>
#include <linux/platform_device.h>
#include <sound/asoundef.h>
#include <sound/control.h>
#include <sound/pcm.h>
struct platform_device;
#define AUD_CONFIG_VALID_BIT (1<<9)
#define AUD_CONFIG_DP_MODE (1<<15)
#define AUD_CONFIG_BLOCK_BIT (1<<7)
......@@ -636,24 +635,4 @@ enum had_event_type {
HAD_EVENT_QUERY_IS_AUDIO_SUSPENDED,
};
/*
* HDMI Display Controller Audio Interface
*
*/
struct hdmi_audio_event {
int type;
};
int mid_hdmi_audio_read(struct platform_device *pdev, u32 reg, u32 *val);
int mid_hdmi_audio_write(struct platform_device *pdev, u32 reg, u32 val);
int mid_hdmi_audio_rmw(struct platform_device *pdev,
u32 reg, u32 val, u32 mask);
int mid_hdmi_audio_get_caps(struct platform_device *pdev,
enum had_caps_list get_element,
void *capabilities);
int mid_hdmi_audio_set_caps(struct platform_device *pdev,
enum had_caps_list set_element,
void *capabilties);
#endif
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