ASoC: hda - Add ASoC Skylake HD audio driver
cover ASoC: hda - Add ASoC Skylake HD audio driver
This series of 11 patches adds support for ASoC Skylake HD Audio driver.
Modified the hda core bus framework to support id_table match for ASoC DEV type instead of adding new wrapper. So dropped below RFC [RFC 3/3] ALSA: hda - add soc hda bus wrapper from the series [RFC 0/3]
ALSA: Add soc hda bus support
Jeeja KP (11):
ALSA: hda - add id table support for hdac device/driver
ALSA: hda - Add generic helper function to register/unregister driver
ALSA: hda - add generic function to unregister all devices on bus
ALSA: hda: corrected snd_hdac_stream_init() declaration
ALSA: hda - exported link_reset enter/exit
ALSA: hda - moved alloc/free stream pages function to controller
library
ALSA: hda - add generic functions to set hdac stream params
ASoC: hda - add Skylake platform driver
ALSA: hda - moved interrupt handler to controller library
ASoC: hda - add Skylake HD audio driver
ASoC: hda - enable ASoC Skylake HD audio driver
include/sound/hdaudio.h | 43 ++- sound/hda/hda_bus_type.c | 2 + sound/hda/hdac_bus.c | 55 +++ sound/hda/hdac_controller.c | 78 ++++- sound/hda/hdac_stream.c | 29 ++ sound/soc/Kconfig | 3 +- sound/soc/Makefile | 1 + sound/soc/hda/Kconfig | 29 ++ sound/soc/hda/Makefile | 6 + sound/soc/hda/hda_skl.c | 829 ++++++++++++++++++++++++++++++++++++++++++++ sound/soc/hda/hda_skl.h | 49 +++ sound/soc/hda/hda_skl_pcm.c | 501 ++++++++++++++++++++++++++ 12 files changed, 1619 insertions(+), 6 deletions(-) create mode 100644 sound/soc/hda/Kconfig create mode 100644 sound/soc/hda/Makefile create mode 100644 sound/soc/hda/hda_skl.c create mode 100644 sound/soc/hda/hda_skl.h create mode 100644 sound/soc/hda/hda_skl_pcm.c
Signature · 1 line
1.9.0
RFC 1/11 ALSA: hda - add id table support for hdac device/driver
From: Jeeja KP <[email protected]>
For device/driver matching, uses id table
if device type is HDA_DEV_ASOC.
--- include/sound/hdaudio.h | 16 ++++++++++++++++ sound/hda/hda_bus_type.c | 2 ++ sound/hda/hdac_bus.c | 24 ++++++++++++++++++++++++ 3 files changed, 42 insertions(+)
include/sound/hdaudio.h +16 -0
@@ -42,6 +42,14 @@ struct hdac_widget_tree;*/ extern struct bus_type snd_hda_bus_type; +/*HDA device table*/ +#define HDA_NAME_SIZE 20 +struct hdac_device_id { +__u32 id; +char name[HDA_NAME_SIZE ]; +unsigned long driver_data; +}; +/* * HD-audio codec base device */
@@ -82,6 +90,8 @@ struct hdac_device {/* sysfs */ struct hdac_widget_tree *widgets; + +const struct hdac_device_id *id_entry; };/* device/driver type used for matching */
@@ -96,6 +106,9 @@ enum {HDA_INPUT ,HDA_OUTPUT }; + +#define hda_get_device_id (pdev) ((pdev)->id_entry) +#define dev_to_hdac_dev (_dev) container_of(_dev, struct hdac_device, dev) int snd_hdac_device_init(struct hdac_device *dev, struct hdac_bus *bus,
@@ -126,12 +139,14 @@ static inline void snd_hdac_power_up(struct hdac_device *codec) {}static inline void snd_hdac_power_down (struct hdac_device *codec) {}#endif +/* * HD-audio codec base driver */ struct hdac_driver {struct device_driver driver;int type; +struct hdac_device_id *id_table;int (*match)(struct hdac_device *dev,struct hdac_driver *drv);void (*unsol_event)(struct hdac_device *dev,unsigned int event); };
@@ -248,6 +263,7 @@ void snd_hdac_bus_queue_event(struct hdac_bus *bus, u32 res, u32 res_ex);int snd_hdac_bus_add_device (struct hdac_bus *bus,struct hdac_device *codec);void snd_hdac_bus_remove_device (struct hdac_bus *bus,struct hdac_device *codec); +int snd_hdac_bus_match_id (struct hdac_device *dev,struct hdac_driver *drv);static inline void snd_hdac_codec_link_up (struct hdac_device *codec) {
sound/hda/hda_bus_type.c +2 -0
@@ -19,6 +19,8 @@ static int hda_bus_match(struct device *dev, struct device_driver *drv)return 0 ;if (hdrv->match)return hdrv->match (hdev, hdrv); +if (hdrv->id_table) +return snd_hdac_bus_match_id (hdev, hdrv);return 1 ; }
sound/hda/hdac_bus.c +24 -0
@@ -195,3 +195,27 @@ void snd_hdac_bus_remove_device(struct hdac_bus *bus, bus->num_codecs--; }EXPORT_SYMBOL_GPL (snd_hdac_bus_remove_device); + +/** +* snd_hdac_bus_match_id - bind hdac device to hdac driver. +* @hdev: device. +* @hdrv: driver. +* +*/ +int snd_hdac_bus_match_id (struct hdac_device *dev, +struct hdac_driver *drv) +{ +if (drv->id_table) { +struct hdac_device_id *id = drv->id_table; + +while (id->name[0 ]) { +if (dev->vendor_id == id->id) { + dev->id_entry = id; +return 1 ; + } + id++; + } + } +return 0 ; +} +EXPORT_SYMBOL_GPL (snd_hdac_bus_match_id);
Signature · 1 line
1.9.0
Re: [RFC 01/11] ALSA: hda - add id table support for hdac device/driver
At Sun, 12 Apr 2015 18:06:08 +0530,
Quoted 111 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
For device/driver matching, uses id table
if device type isHDA_DEV_ASOC.Signed-off-by Jeeja KP <[email protected]>Signed-off-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- include/sound/hdaudio.h | 16 ++++++++++++++++ sound/hda/hda_bus_type.c | 2 ++ sound/hda/hdac_bus.c | 24 ++++++++++++++++++++++++ 3 files changed, 42 insertions(+)include/sound/hdaudio.h +16
-0@@ -42,6 +42,14 @@ struct hdac_widget_tree;*/ extern struct bus_type snd_hda_bus_type; +/*HDA device table*/ +#define HDA_NAME_SIZE 20 +struct hdac_device_id { +__u32 id; +char name[HDA_NAME_SIZE ]; +unsigned long driver_data; +}; +/* * HD-audio codec base device */ @@ -82,6 +90,8 @@ struct hdac_device {/* sysfs */ struct hdac_widget_tree *widgets; + +const struct hdac_device_id *id_entry; };/* device/driver type used for matching */ @@ -96,6 +106,9 @@ enum {HDA_INPUT ,HDA_OUTPUT }; + +#define hda_get_device_id (pdev) ((pdev)->id_entry) +#define dev_to_hdac_dev (_dev) container_of(_dev, struct hdac_device, dev) int snd_hdac_device_init(struct hdac_device *dev, struct hdac_bus *bus,@@ -126,12 +139,14 @@ static inline void snd_hdac_power_up(struct hdac_device *codec) {}static inline void snd_hdac_power_down (struct hdac_device *codec) {}#endif +/* * HD-audio codec base driver */ struct hdac_driver {struct device_driver driver;int type; +struct hdac_device_id *id_table;int (*match)(struct hdac_device *dev,struct hdac_driver *drv);void (*unsol_event)(struct hdac_device *dev,unsigned int event); };@@ -248,6 +263,7 @@ void snd_hdac_bus_queue_event(struct hdac_bus *bus, u32 res, u32 res_ex);int snd_hdac_bus_add_device (struct hdac_bus *bus,struct hdac_device *codec);void snd_hdac_bus_remove_device (struct hdac_bus *bus,struct hdac_device *codec); +int snd_hdac_bus_match_id (struct hdac_device *dev,struct hdac_driver *drv);static inline void snd_hdac_codec_link_up (struct hdac_device *codec) {sound/hda/hda_bus_type.c +2
-0@@ -19,6 +19,8 @@ static int hda_bus_match(struct device *dev, struct device_driver *drv)return 0 ;if (hdrv->match)return hdrv->match (hdev, hdrv); +if (hdrv->id_table) +return snd_hdac_bus_match_id (hdev, hdrv);return 1 ; }sound/hda/hdac_bus.c +14
-0@@ -195,3 +195,27 @@ void snd_hdac_bus_remove_device(struct hdac_bus *bus, bus->num_codecs--; }EXPORT_SYMBOL_GPL (snd_hdac_bus_remove_device); + +/** +* snd_hdac_bus_match_id - bind hdac device to hdac driver. +* @hdev: device. +* @hdrv: driver. +* +*/ +int snd_hdac_bus_match_id (struct hdac_device *dev, +struct hdac_driver *drv) +{ +if (drv->id_table) { +struct hdac_device_id *id = drv->id_table; + +while (id->name[0 ]) {
sound/hda/hdac_bus.c void snd_hdac_bus_remove_device(struct hdac_bus *bus, · line 221
Quoted 10 lines
sound/hda/hdac_bus.c +10
-0+if (dev->vendor_id == id->id) { + dev->id_entry = id; +return 1 ; + } + id++; + } + } +return 0 ; +} +EXPORT_SYMBOL_GPL (snd_hdac_bus_match_id);
Please make these rather ASoC specific. These ID checks aren't needed for the legacy driver as they need more other fields checks like revision id.
For example,
struct hda_soc_device {
struct hdac_device core;
const struct hda_soc_device_id *id_entry;
....
};and give the match ops to hdac_driver for checking the ID.
thanks,
Takashi
Re: [RFC 01/11] ALSA: hda - add id table support for hdac device/driver
Quoted 56 lines · Takashi Iwai
At Sun, 12 Apr 2015 18:06:08 +0530,
Quoted 37 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
sound/hda/hda_bus_type.c +2
-0@@ -19,6 +19,8 @@ static int hda_bus_match(struct device *dev, struct device_driver *drv)return 0 ;if (hdrv->match)return hdrv->match (hdev, hdrv); +if (hdrv->id_table) +return snd_hdac_bus_match_id (hdev, hdrv);return 1 ; }sound/hda/hdac_bus.c +14
-0@@ -195,3 +195,27 @@ void snd_hdac_bus_remove_device(struct hdac_bus *bus, bus->num_codecs--; }EXPORT_SYMBOL_GPL (snd_hdac_bus_remove_device); + +/** +* snd_hdac_bus_match_id - bind hdac device to hdac driver. +* @hdev: device. +* @hdrv: driver. +* +*/ +int snd_hdac_bus_match_id (struct hdac_device *dev, +struct hdac_driver *drv) +{ +if (drv->id_table) { +struct hdac_device_id *id = drv->id_table; + +while (id->name[0 ]) {sound/hda/hdac_bus.c void snd_hdac_bus_remove_device(struct hdac_bus *bus, · line 221
Quoted 10 lines
sound/hda/hdac_bus.c +10
-0+if (dev->vendor_id == id->id) { + dev->id_entry = id; +return 1 ; + } + id++; + } + } +return 0 ; +} +EXPORT_SYMBOL_GPL (snd_hdac_bus_match_id);Please make these rather ASoC specific. These ID checks aren't needed for the legacy driver as they need more other fields checks like revision id.
For example,
Quoted 7 lines
struct hda_soc_device { struct hdac_device core; const struct hda_soc_device_id *id_entry; .... };and give the match ops to
hdac_driverfor checking the ID.
Okay, will move these to asoc then. I am planning to move this to generic asoc layer and not in skl driver specfic
Signature · 1 line
~Vinod
RFC 2/11 ALSA: hda - Add generic helper function to register/unregister driver
In reply to Subhransu S. PrustyFrom: Jeeja KP <[email protected]>
ASOC HD codec drivers will use the generic functions to register/unregister driver
--- include/sound/hdaudio.h | 3 +++ sound/hda/hdac_bus.c | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+)
include/sound/hdaudio.h +3 -0
@@ -153,6 +153,9 @@ struct hdac_driver {#define drv_to_hdac_driver (_drv) container_of(_drv, struct hdac_driver, driver) +int snd_hdac_driver_register (struct hdac_driver *drv); +void snd_hdac_driver_unregister (struct hdac_driver *drv); +/* * HD-audio bus base driver */
sound/hda/hdac_bus.c +21 -0
@@ -219,3 +219,24 @@ int snd_hdac_bus_match_id(struct hdac_device *dev,return 0 ; }EXPORT_SYMBOL_GPL (snd_hdac_bus_match_id); + +/** +* snd_hdac_driver_register - register a driver for hda devices +* @drv: hdac driver structure +*/ +int snd_hdac_driver_register (struct hdac_driver *drv) +{ + drv->driver.bus = &snd_hda_bus_type; +return driver_register (&drv->driver); +} +EXPORT_SYMBOL_GPL (snd_hdac_driver_register); + +/** +* snd_hdac_driver_unregister - unregister a driver for hda devices +* @drv: hdac driver structure +*/ +void snd_hdac_driver_unregister (struct hdac_driver *drv) +{ +driver_unregister (&drv->driver); +} +EXPORT_SYMBOL_GPL (snd_hdac_driver_unregister);
Signature · 1 line
1.9.0
Re: [RFC 02/11] ALSA: hda - Add generic helper function to register/unregister driver
At Sun, 12 Apr 2015 18:06:09 +0530,
Quoted 47 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
ASOC HD codec drivers will use the generic functions to register/unregister driver
Signed-off-by Jeeja KP <[email protected]>Signed-off-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- include/sound/hdaudio.h | 3 +++ sound/hda/hdac_bus.c | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+)include/sound/hdaudio.h +3
-0@@ -153,6 +153,9 @@ struct hdac_driver {#define drv_to_hdac_driver (_drv) container_of(_drv, struct hdac_driver, driver) +int snd_hdac_driver_register (struct hdac_driver *drv); +void snd_hdac_driver_unregister (struct hdac_driver *drv); +/* * HD-audio bus base driver */ sound/hda/hdac_bus.c +11
-0@@ -219,3 +219,24 @@ int snd_hdac_bus_match_id(struct hdac_device *dev,return 0 ; }EXPORT_SYMBOL_GPL (snd_hdac_bus_match_id); + +/** +* snd_hdac_driver_register - register a driver for hda devices +* @drv: hdac driver structure +*/ +int snd_hdac_driver_register (struct hdac_driver *drv) +{ + drv->driver.bus = &snd_hda_bus_type; +return driver_register (&drv->driver); +} +EXPORT_SYMBOL_GPL (snd_hdac_driver_register);
sound/hda/hdac_bus.c int snd_hdac_bus_match_id(struct hdac_device *dev, · line 242
Quoted 10 lines
sound/hda/hdac_bus.c +10
-0+ +/** +* snd_hdac_driver_unregister - unregister a driver for hda devices +* @drv: hdac driver structure +*/ +void snd_hdac_driver_unregister (struct hdac_driver *drv) +{ +driver_unregister (&drv->driver); +} +EXPORT_SYMBOL_GPL (snd_hdac_driver_unregister);
Hrm, I see no big merits to wrap such a single function call. Once when struct hdac_driver itself is embedded, another redirection is needed.
thanks,
Takashi
RFC 3/11 ALSA: hda - add generic function to unregister all devices on bus
In reply to Subhransu S. PrustyFrom: Jeeja KP <[email protected]>
This will be used by SKL controller in driver remove to unregister all hda devices added during probe.
--- include/sound/hdaudio.h | 2 ++ sound/hda/hdac_bus.c | 10 ++++++++++ 2 files changed, 12 insertions(+)
include/sound/hdaudio.h +2 -0
@@ -268,6 +268,8 @@ void snd_hdac_bus_remove_device(struct hdac_bus *bus, struct hdac_device *codec);int snd_hdac_bus_match_id (struct hdac_device *dev,struct hdac_driver *drv); +void snd_hdac_bus_device_unregister (struct hdac_bus *bus); +static inline void snd_hdac_codec_link_up (struct hdac_device *codec) {set_bit (codec->addr, &codec->bus->codec_powered);
sound/hda/hdac_bus.c +10 -0
@@ -240,3 +240,13 @@ void snd_hdac_driver_unregister(struct hdac_driver *drv)driver_unregister (&drv->driver); }EXPORT_SYMBOL_GPL (snd_hdac_driver_unregister); + +void snd_hdac_bus_device_unregister (struct hdac_bus *bus) +{ +struct hdac_device *hdev; + +/*unregister all devices on bus */ +list_for_each_entry (hdev, &bus->codec_list, list) +snd_hdac_device_unregister (hdev); +} +EXPORT_SYMBOL_GPL (snd_hdac_bus_device_unregister);
Signature · 1 line
1.9.0
Re: [RFC 03/11] ALSA: hda - add generic function to unregister all devices on bus
At Sun, 12 Apr 2015 18:06:10 +0530,
Quoted 35 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
This will be used by SKL controller in driver remove to unregister all hda devices added during probe.
Signed-off-by Jeeja KP <[email protected]>Signed-off-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- include/sound/hdaudio.h | 2 ++ sound/hda/hdac_bus.c | 10 ++++++++++ 2 files changed, 12 insertions(+)include/sound/hdaudio.h +2
-0@@ -268,6 +268,8 @@ void snd_hdac_bus_remove_device(struct hdac_bus *bus, struct hdac_device *codec);int snd_hdac_bus_match_id (struct hdac_device *dev,struct hdac_driver *drv); +void snd_hdac_bus_device_unregister (struct hdac_bus *bus); +static inline void snd_hdac_codec_link_up (struct hdac_device *codec) {set_bit (codec->addr, &codec->bus->codec_powered);sound/hda/hdac_bus.c +0
-0@@ -240,3 +240,13 @@ void snd_hdac_driver_unregister(struct hdac_driver *drv)driver_unregister (&drv->driver); }EXPORT_SYMBOL_GPL (snd_hdac_driver_unregister);
sound/hda/hdac_bus.c void snd_hdac_driver_unregister(struct hdac_driver *drv) · line 252
Quoted 10 lines
sound/hda/hdac_bus.c +10
-0+ +void snd_hdac_bus_device_unregister (struct hdac_bus *bus) +{ +struct hdac_device *hdev; + +/*unregister all devices on bus */ +list_for_each_entry (hdev, &bus->codec_list, list) +snd_hdac_device_unregister (hdev); +} +EXPORT_SYMBOL_GPL (snd_hdac_bus_device_unregister);
Again, I don't think we need to keep this in the core code until it's really shared among multiple drivers.
thanks,
Takashi
Re: [RFC 03/11] ALSA: hda - add generic function to unregister all devices on bus
Quoted 42 lines · Takashi Iwai
At Sun, 12 Apr 2015 18:06:10 +0530,
Quoted 40 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
This will be used by SKL controller in driver remove to unregister all hda devices added during probe.
Signed-off-by Jeeja KP <[email protected]>Signed-off-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- include/sound/hdaudio.h | 2 ++ sound/hda/hdac_bus.c | 10 ++++++++++ 2 files changed, 12 insertions(+)include/sound/hdaudio.h +2
-0@@ -268,6 +268,8 @@ void snd_hdac_bus_remove_device(struct hdac_bus *bus, struct hdac_device *codec);int snd_hdac_bus_match_id (struct hdac_device *dev,struct hdac_driver *drv); +void snd_hdac_bus_device_unregister (struct hdac_bus *bus); +static inline void snd_hdac_codec_link_up (struct hdac_device *codec) {set_bit (codec->addr, &codec->bus->codec_powered);sound/hda/hdac_bus.c +5
-0@@ -240,3 +240,13 @@ void snd_hdac_driver_unregister(struct hdac_driver *drv)driver_unregister (&drv->driver); }EXPORT_SYMBOL_GPL (snd_hdac_driver_unregister); + +void snd_hdac_bus_device_unregister (struct hdac_bus *bus) +{ +struct hdac_device *hdev; +
Quoted 8 lines
sound/hda/hdac_bus.c void snd_hdac_driver_unregister(struct hdac_driver *drv) · line 252
Quoted 5 lines
sound/hda/hdac_bus.c +5
-0+/*unregister all devices on bus */ +list_for_each_entry (hdev, &bus->codec_list, list) +snd_hdac_device_unregister (hdev); +} +EXPORT_SYMBOL_GPL (snd_hdac_bus_device_unregister);Again, I don't think we need to keep this in the core code until it's really shared among multiple drivers.
Sure, since this was quote generic we kept it in corre, but its fine in asoc too
Signature · 1 line
~Vinod
RFC 4/11 ALSA: hda: corrected snd_hdac_stream_init() declaration
In reply to Subhransu S. PrustyFrom: Jeeja KP <[email protected]>
Corrected snd_hdac_stream_init() declaration in header file.
--- include/sound/hdaudio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/sound/hdaudio.h +1 -1
@@ -340,7 +340,7 @@ struct hdac_stream {struct mutex dsp_mutex; }; -void snd_hdac_bus_stream_init (struct hdac_bus *bus,struct hdac_stream *azx_dev, +void snd_hdac_stream_init (struct hdac_bus *bus,struct hdac_stream *azx_dev,int idx,int direction,int tag);struct hdac_stream *snd_hdac_stream_assign (struct hdac_bus *bus,struct snd_pcm_substream *substream);
Signature · 1 line
1.9.0
Re: [RFC 04/11] ALSA: hda: corrected snd_hdac_stream_init() declaration
At Sun, 12 Apr 2015 18:06:11 +0530,
Quoted 17 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
Corrected
snd_hdac_stream_init()declaration in header file.Signed-off-by Jeeja KP <[email protected]>Signed-off-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- include/sound/hdaudio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/sound/hdaudio.h +0
-0
include/sound/hdaudio.h struct hdac_stream { · line 346
Quoted 8 lines
include/sound/hdaudio.h +1
-1@@ -340,7 +340,7 @@ struct hdac_stream {struct mutex dsp_mutex; }; -void snd_hdac_bus_stream_init (struct hdac_bus *bus,struct hdac_stream *azx_dev, +void snd_hdac_stream_init (struct hdac_bus *bus,struct hdac_stream *azx_dev,int idx,int direction,int tag);struct hdac_stream *snd_hdac_stream_assign (struct hdac_bus *bus,struct snd_pcm_substream *substream);
I suppose you're referring to the code in topic/hda-dev2 branch of sound-unstable git tree? Then I'll fold the fix into it.
thanks,
Takashi
Re: [RFC 04/11] ALSA: hda: corrected snd_hdac_stream_init() declaration
Quoted 22 lines · Takashi Iwai
At Sun, 12 Apr 2015 18:06:11 +0530,
Quoted 20 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
Corrected
snd_hdac_stream_init()declaration in header file.Signed-off-by Jeeja KP <[email protected]>Signed-off-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- include/sound/hdaudio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/sound/hdaudio.h +0
-0@@ -340,7 +340,7 @@ struct hdac_stream {struct mutex dsp_mutex; };
Quoted 8 lines
include/sound/hdaudio.h struct hdac_stream { · line 346
Quoted 5 lines
include/sound/hdaudio.h +1
-1-void snd_hdac_bus_stream_init (struct hdac_bus *bus,struct hdac_stream *azx_dev, +void snd_hdac_stream_init (struct hdac_bus *bus,struct hdac_stream *azx_dev,int idx,int direction,int tag);struct hdac_stream *snd_hdac_stream_assign (struct hdac_bus *bus,struct snd_pcm_substream *substream);I suppose you're referring to the code in topic/hda-dev2 branch of sound-unstable git tree? Then I'll fold the fix into it.
Yes all the code is based on 7 patches you had posted plus the patch series V3 I had sent (which is based on hda-dev2). Please do fold this up and push updated barcnh for me so that I cna rebase these
Signature · 1 line
~Vinod
RFC 5/11 ALSA: hda - exported link_reset enter/exit
In reply to Subhransu S. PrustyFrom: Jeeja KP <[email protected]>
Exported azx_enter_link_reset and azx_exit_link_reset functions to be used by the SKL controller driver
--- include/sound/hdaudio.h | 3 +++ sound/hda/hdac_controller.c | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-)
include/sound/hdaudio.h +3 -0
@@ -286,6 +286,8 @@ int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr,void snd_hdac_bus_init_chip (struct hdac_bus *bus,bool full_reset);void snd_hdac_bus_stop_chip (struct hdac_bus *bus); +void snd_hdac_bus_enter_link_reset (struct hdac_bus *bus); +void snd_hdac_bus_exit_link_reset (struct hdac_bus *bus);void snd_hdac_bus_update_rirb (struct hdac_bus *bus); void snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status,
@@ -359,6 +361,7 @@ void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start, unsigned int streams);void snd_hdac_stream_timecounter_init (struct hdac_stream *azx_dev,unsigned int streams); +/*DSP loader functions */ int snd_hdac_load_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format, unsigned int byte_size,
sound/hda/hdac_controller.c +6 -4
@@ -212,7 +212,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_get_response);*/ /* enter link reset */ -static void azx_enter_link_reset (struct hdac_bus *bus) +void snd_hdac_bus_enter_link_reset (struct hdac_bus *bus) {unsigned long timeout;
@@ -224,9 +224,10 @@ static void azx_enter_link_reset(struct hdac_bus *bus) time_before(jiffies, timeout))usleep_range (500 ,1000 ); } +EXPORT_SYMBOL_GPL (snd_hdac_bus_enter_link_reset);/* exit link reset */ -static void azx_exit_link_reset (struct hdac_bus *bus) +void snd_hdac_bus_exit_link_reset (struct hdac_bus *bus) {unsigned long timeout;
@@ -236,6 +237,7 @@ static void azx_exit_link_reset(struct hdac_bus *bus)while (!azx_readb (bus,GCTL ) &&time_before (jiffies, timeout))usleep_range (500 ,1000 ); } +EXPORT_SYMBOL_GPL (snd_hdac_bus_exit_link_reset);/* reset codec link */ static int azx_reset (struct hdac_bus *bus,bool full_reset)
@@ -247,7 +249,7 @@ static int azx_reset(struct hdac_bus *bus, bool full_reset)azx_writew (bus,STATESTS ,STATESTS_INT_MASK );/* reset controller */ -azx_enter_link_reset (bus); +snd_hdac_bus_enter_link_reset (bus);/* delay for >= 100us for codec PLL to settle per spec * Rev 0.9 section 5.5.1
@@ -255,7 +257,7 @@ static int azx_reset(struct hdac_bus *bus, bool full_reset)usleep_range (500 ,1000 );/* Bring controller out of reset */ -azx_exit_link_reset (bus); +snd_hdac_bus_exit_link_reset (bus);/* Brent Chartrand said to wait >= 540us for codecs to initialize */ usleep_range (1000 ,1200 );
Signature · 1 line
1.9.0
Re: [RFC 05/11] ALSA: hda - exported link_reset enter/exit
At Sun, 12 Apr 2015 18:06:12 +0530,
Quoted 5 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
Exported
azx_enter_link_resetandazx_exit_link_resetfunctions to be used by the SKL controller driver
OK, I can fold them to my patchset.
Takashi
Quoted 83 lines
Signed-off-by Jeeja KP <[email protected]>Signed-off-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- include/sound/hdaudio.h | 3 +++ sound/hda/hdac_controller.c | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-)include/sound/hdaudio.h +3
-0@@ -286,6 +286,8 @@ int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr,void snd_hdac_bus_init_chip (struct hdac_bus *bus,bool full_reset);void snd_hdac_bus_stop_chip (struct hdac_bus *bus); +void snd_hdac_bus_enter_link_reset (struct hdac_bus *bus); +void snd_hdac_bus_exit_link_reset (struct hdac_bus *bus);void snd_hdac_bus_update_rirb (struct hdac_bus *bus); void snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status,@@ -359,6 +361,7 @@ void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start, unsigned int streams);void snd_hdac_stream_timecounter_init (struct hdac_stream *azx_dev,unsigned int streams); +/*DSP loader functions */ int snd_hdac_load_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format, unsigned int byte_size,sound/hda/hdac_controller.c +6
-4@@ -212,7 +212,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_get_response);*/ /* enter link reset */ -static void azx_enter_link_reset (struct hdac_bus *bus) +void snd_hdac_bus_enter_link_reset (struct hdac_bus *bus) {unsigned long timeout;@@ -224,9 +224,10 @@ static void azx_enter_link_reset(struct hdac_bus *bus) time_before(jiffies, timeout))usleep_range (500 ,1000 ); } +EXPORT_SYMBOL_GPL (snd_hdac_bus_enter_link_reset);/* exit link reset */ -static void azx_exit_link_reset (struct hdac_bus *bus) +void snd_hdac_bus_exit_link_reset (struct hdac_bus *bus) {unsigned long timeout;@@ -236,6 +237,7 @@ static void azx_exit_link_reset(struct hdac_bus *bus)while (!azx_readb (bus,GCTL ) &&time_before (jiffies, timeout))usleep_range (500 ,1000 ); } +EXPORT_SYMBOL_GPL (snd_hdac_bus_exit_link_reset);/* reset codec link */ static int azx_reset (struct hdac_bus *bus,bool full_reset)@@ -247,7 +249,7 @@ static int azx_reset(struct hdac_bus *bus, bool full_reset)azx_writew (bus,STATESTS ,STATESTS_INT_MASK );/* reset controller */ -azx_enter_link_reset (bus); +snd_hdac_bus_enter_link_reset (bus);/* delay for >= 100us for codec PLL to settle per spec * Rev 0.9 section 5.5.1 @@ -255,7 +257,7 @@ static int azx_reset(struct hdac_bus *bus, bool full_reset)usleep_range (500 ,1000 );/* Bring controller out of reset */ -azx_exit_link_reset (bus); +snd_hdac_bus_exit_link_reset (bus);/* Brent Chartrand said to wait >= 540us for codecs to initialize */ usleep_range (1000 ,1200 );Signature · 1 line
1.9.0
Re: [RFC 05/11] ALSA: hda - exported link_reset enter/exit
Quoted 9 lines · Takashi Iwai
At Sun, 12 Apr 2015 18:06:12 +0530,
Quoted 5 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
Exported
azx_enter_link_resetandazx_exit_link_resetfunctions to be used by the SKL controller driverOK, I can fold them to my patchset.
Sounds good :)
Signature · 1 line
~Vinod
RFC 6/11 ALSA: hda - moved alloc/free stream pages function to controller library
In reply to Subhransu S. PrustyFrom: Jeeja KP <[email protected]>
Moved azx_alloc_stream_pages and azx_free_stream_pages to controller library.
--- include/sound/hdaudio.h | 3 +++ sound/hda/hdac_controller.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
include/sound/hdaudio.h +3 -0
@@ -294,6 +294,9 @@ void snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status,void (*ack)(struct hdac_bus *, struct hdac_stream *)); +int snd_hdac_bus_alloc_stream_pages (struct hdac_bus *bus); +void snd_hdac_bus_free_stream_pages (struct hdac_bus *bus); +/* * HD-audio stream */
sound/hda/hdac_controller.c +44 -0
47 lines not on this page · raw message
Signature · 1 line
1.9.0
RFC 7/11 ALSA: hda - add generic functions to set hdac stream params
In reply to Subhransu S. PrustyFrom: Jeeja KP <[email protected]>
This will be used by hda controller driver to setup stream params in prepare. This function will setup the bdl and periods.
--- include/sound/hdaudio.h | 2 ++ sound/hda/hdac_stream.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
include/sound/hdaudio.h +2 -0
@@ -364,6 +364,8 @@ void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start, unsigned int streams);void snd_hdac_stream_timecounter_init (struct hdac_stream *azx_dev,unsigned int streams); +int snd_set_hdac_stream_params (struct hdac_stream *azx_dev, +unsigned int format_val);/*DSP loader functions */ int snd_hdac_load_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format,
sound/hda/hdac_stream.c +29 -0
@@ -472,6 +472,35 @@ void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start, }EXPORT_SYMBOL_GPL (snd_hdac_stream_sync); +int snd_set_hdac_stream_params (struct hdac_stream *azx_dev, +unsigned int format_val) +{ + +unsigned int bufsize, period_bytes; +struct snd_pcm_substream *substream = azx_dev->substream; +struct snd_pcm_runtime *runtime = substream->runtime; +int err; + + bufsize =snd_pcm_lib_buffer_bytes (substream); + period_bytes =snd_pcm_lib_period_bytes (substream); + +if (bufsize != azx_dev->bufsize || + period_bytes != azx_dev->period_bytes || + format_val != azx_dev->format_val || + runtime->no_period_wakeup != azx_dev->no_period_wakeup) { + azx_dev->bufsize = bufsize; + azx_dev->period_bytes = period_bytes; + azx_dev->format_val = format_val; + azx_dev->no_period_wakeup = runtime->no_period_wakeup; + err =snd_hdac_stream_setup_periods (azx_dev); +if (err <0 ) +return err; + } +return 0 ; +} +EXPORT_SYMBOL_GPL (snd_set_hdac_stream_params); + +int snd_hdac_load_dsp_prepare (struct hdac_stream *azx_dev,unsigned int format,unsigned int byte_size,struct snd_dma_buffer *bufp)
Signature · 1 line
1.9.0
Re: [RFC 07/11] ALSA: hda - add generic functions to set hdac stream params
At Sun, 12 Apr 2015 18:06:14 +0530,
Quoted 33 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
This will be used by hda controller driver to setup stream params in prepare. This function will setup the bdl and periods.
Signed-off-by Jeeja KP <[email protected]>Signed-off-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- include/sound/hdaudio.h | 2 ++ sound/hda/hdac_stream.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)include/sound/hdaudio.h +2
-0@@ -364,6 +364,8 @@ void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start, unsigned int streams);void snd_hdac_stream_timecounter_init (struct hdac_stream *azx_dev,unsigned int streams); +int snd_set_hdac_stream_params (struct hdac_stream *azx_dev, +unsigned int format_val);/*DSP loader functions */ int snd_hdac_load_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format,sound/hda/hdac_stream.c +0
-0
sound/hda/hdac_stream.c void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start, · line 476
Quoted 5 lines
sound/hda/hdac_stream.c +2
-0@@ -472,6 +472,35 @@ void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start, }EXPORT_SYMBOL_GPL (snd_hdac_stream_sync); +int snd_set_hdac_stream_params (struct hdac_stream *azx_dev, +unsigned int format_val)
I'd name it a bit more consistently, e.g. snd_hdac_stream_set_format() or snd_hdac_stream_set_params() or so.
sound/hda/hdac_stream.c void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start, · line 481
Quoted 5 lines
sound/hda/hdac_stream.c +5
-0+{ + +unsigned int bufsize, period_bytes; +struct snd_pcm_substream *substream = azx_dev->substream; +struct snd_pcm_runtime *runtime = substream->runtime;
I would do a NULL check for substream to be sure.
thanks,
Takashi
Quoted 28 lines
sound/hda/hdac_stream.c +22
-0+int err; + + bufsize =snd_pcm_lib_buffer_bytes (substream); + period_bytes =snd_pcm_lib_period_bytes (substream); + +if (bufsize != azx_dev->bufsize || + period_bytes != azx_dev->period_bytes || + format_val != azx_dev->format_val || + runtime->no_period_wakeup != azx_dev->no_period_wakeup) { + azx_dev->bufsize = bufsize; + azx_dev->period_bytes = period_bytes; + azx_dev->format_val = format_val; + azx_dev->no_period_wakeup = runtime->no_period_wakeup; + err =snd_hdac_stream_setup_periods (azx_dev); +if (err <0 ) +return err; + } +return 0 ; +} +EXPORT_SYMBOL_GPL (snd_set_hdac_stream_params); + +int snd_hdac_load_dsp_prepare (struct hdac_stream *azx_dev,unsigned int format,unsigned int byte_size,struct snd_dma_buffer *bufp)Signature · 1 line
1.9.0
Re: [RFC 07/11] ALSA: hda - add generic functions to set hdac stream params
Quoted 38 lines · Takashi Iwai
At Sun, 12 Apr 2015 18:06:14 +0530,
Quoted 36 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
This will be used by hda controller driver to setup stream params in prepare. This function will setup the bdl and periods.
Signed-off-by Jeeja KP <[email protected]>Signed-off-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- include/sound/hdaudio.h | 2 ++ sound/hda/hdac_stream.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)include/sound/hdaudio.h +2
-0@@ -364,6 +364,8 @@ void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start, unsigned int streams);void snd_hdac_stream_timecounter_init (struct hdac_stream *azx_dev,unsigned int streams); +int snd_set_hdac_stream_params (struct hdac_stream *azx_dev, +unsigned int format_val);/*DSP loader functions */ int snd_hdac_load_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format,sound/hda/hdac_stream.c +0
-0@@ -472,6 +472,35 @@ void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start, }EXPORT_SYMBOL_GPL (snd_hdac_stream_sync);
Quoted 5 lines
sound/hda/hdac_stream.c void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start, · line 476
Quoted 2 lines
sound/hda/hdac_stream.c +2
-0+int snd_set_hdac_stream_params (struct hdac_stream *azx_dev, +unsigned int format_val)I'd name it a bit more consistently, e.g.
snd_hdac_stream_set_format()orsnd_hdac_stream_set_params()or so.
Ah thats a bad miss on our side, will fix in next rev
Quoted 8 lines
sound/hda/hdac_stream.c void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start, · line 481
Quoted 6 lines
sound/hda/hdac_stream.c +5
-0+{ + +unsigned int bufsize, period_bytes; +struct snd_pcm_substream *substream = azx_dev->substream; +struct snd_pcm_runtime *runtime = substream->runtime;I would do a NULL check for substream to be sure.
sure...
Signature · 1 line
~Vinod
RFC 8/11 ASoC: hda - add Skylake platform driver
In reply to Subhransu S. PrustyFrom: Jeeja KP <[email protected]>
Defines SoC cpu dais, DMA driver ops and
implements ALSA operations for SKL.
--- sound/soc/hda/hda_skl_pcm.c | 501 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 501 insertions(+) create mode 100644 sound/soc/hda/hda_skl_pcm.c
sound/soc/hda/hda_skl_pcm.c new file +501 -0
@@ -0,0 +1,501 @@ +/* +* hda_skl_pcm.c -ASOC HDA Platform driver file implementing PCM functionality +* +* Copyright (C) 2015 Intel Corp +* Author: Jeeja KP <[email protected]> +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; version 2 of the License. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* +*/ +#include <linux/pci.h> +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <sound/soc.h> +#include <sound/hdaudio.h> +#include "hda_skl.h" + +static struct snd_pcm_hardware azx_pcm_hw = { + .info = (SNDRV_PCM_INFO_MMAP | +SNDRV_PCM_INFO_INTERLEAVED | +SNDRV_PCM_INFO_BLOCK_TRANSFER | +SNDRV_PCM_INFO_MMAP_VALID | +/* No full-resume yet implemented */ +/* SNDRV_PCM_INFO_RESUME |*/ +SNDRV_PCM_INFO_PAUSE | +SNDRV_PCM_INFO_SYNC_START | +SNDRV_PCM_INFO_HAS_WALL_CLOCK |/* legacy */ +SNDRV_PCM_INFO_HAS_LINK_ATIME | +SNDRV_PCM_INFO_NO_PERIOD_WAKEUP ), + .formats =SNDRV_PCM_FMTBIT_S16_LE , + .rates =SNDRV_PCM_RATE_48000 , + .rate_min =48000 , + .rate_max =48000 , + .channels_min =2 , + .channels_max =2 , + .buffer_bytes_max =AZX_MAX_BUF_SIZE , + .period_bytes_min =128 , + .period_bytes_max =AZX_MAX_BUF_SIZE /2 , + .periods_min =2 , + .periods_max =AZX_MAX_FRAG , + .fifo_size =0 , +}; +static inline +struct hdac_stream *get_azx_dev (struct snd_pcm_substream *substream) +{ +return substream->runtime->private_data; +} + +static struct hdac_bus *get_chip_ctx (struct snd_pcm_substream *substream) +{ +struct snd_soc_pcm_runtime *rtd =snd_pcm_substream_chip (substream); +struct device *dev = rtd->cpu_dai->dev; +struct hdac_bus *chip =dev_get_drvdata (dev); +return chip; +} + +static int substream_alloc_pages (struct hdac_bus *chip, +struct snd_pcm_substream *substream, +size_t size) +{ +struct hdac_stream *azx_dev =get_azx_dev (substream); +int ret; + + azx_dev->bufsize =0 ; + azx_dev->period_bytes =0 ; + azx_dev->format_val =0 ; + ret =snd_pcm_lib_malloc_pages (substream, size); +if (ret <0 ) +return ret; +return 0 ; +} + +static int substream_free_pages (struct hdac_bus *chip, +struct snd_pcm_substream *substream) +{ +return snd_pcm_lib_free_pages (substream); +} + +void soc_hda_set_pcm_constrains (struct hdac_bus *bus, +struct snd_pcm_runtime *runtime) +{ +snd_pcm_hw_constraint_integer (runtime,SNDRV_PCM_HW_PARAM_PERIODS ); + +/* avoid wrap-around with wall-clock */ +snd_pcm_hw_constraint_minmax (runtime,SNDRV_PCM_HW_PARAM_BUFFER_TIME , +20 , +178000000 ); + +} + +static int soc_hda_pcm_open (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct hdac_bus *chip =dev_get_drvdata (dai->dev); +struct hdac_stream *azx_dev; +struct snd_pcm_runtime *runtime = substream->runtime; +struct soc_hda_dma_params *dma_params; + +dev_dbg (dai->dev,"%s: %s\n" , __func__, dai->name); + azx_dev =snd_hdac_stream_assign (chip, substream); +if (azx_dev ==NULL ) +return -EBUSY ; + +soc_hda_set_pcm_constrains (chip, runtime); + +/* disable WALLCLOCK timestamps for capture streams +* until we figure out how to handle digital inputs +*/ +if (substream->stream ==SNDRV_PCM_STREAM_CAPTURE ) { + runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_WALL_CLOCK ;/* legacy */ + runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_LINK_ATIME ; + } + + runtime->private_data = azx_dev; + + dma_params =kzalloc (sizeof (*dma_params),GFP_KERNEL ); + dma_params->stream_tag = azx_dev->stream_tag; +snd_soc_dai_set_dma_data (dai, substream, (void *)dma_params); + +dev_dbg (dai->dev,"stream tag set in dma params=%d\n" , + dma_params->stream_tag); +snd_pcm_set_sync (substream); +return 0 ; +} +static int soc_hda_pcm_prepare (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct snd_soc_pcm_runtime *rtd =snd_pcm_substream_chip (substream); +struct hdac_stream *azx_dev =get_azx_dev (substream); +unsigned int format_val; +int err; +struct soc_hda_dma_params *dma_params; +struct snd_soc_dai *codec_dai = rtd->codec_dai; + +dev_dbg (dai->dev,"%s: %s\n" , __func__, dai->name); +if (azx_dev->prepared) { +dev_dbg (dai->dev,"already stream is prepared - returning\n" ); +return 0 ; + } + + dma_params = (struct soc_hda_dma_params *) +snd_soc_dai_get_dma_data (codec_dai, substream); + format_val = dma_params->format; + +dev_dbg (dai->dev,"stream_tag=%d formatvalue=%d\n" , + azx_dev->stream_tag, format_val); +snd_hdac_stream_reset (azx_dev); + + err =snd_set_hdac_stream_params (azx_dev, format_val); + +if (err <0 ) +return err; +snd_hdac_stream_setup (azx_dev); + azx_dev->prepared =1 ; +return err; +} + +static int soc_hda_pcm_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params, +struct snd_soc_dai *dai) +{ +struct hdac_bus *chip =dev_get_drvdata (dai->dev); +int ret; +struct snd_pcm_runtime *runtime = substream->runtime; + +dev_dbg (dai->dev,"%s: %s\n" , __func__, dai->name); + ret =substream_alloc_pages (chip, substream, +params_buffer_bytes (params)); + +memset (substream->runtime->dma_area,0 ,params_buffer_bytes (params)); + +dev_dbg (dai->dev,"format_val, rate=%d, ch=%d, format=%d\n" , + runtime->rate, runtime->channels, runtime->format); + +return ret; +} + +static void soc_hda_pcm_close (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct hdac_stream *azx_dev =get_azx_dev (substream); +struct soc_hda_dma_params *dma_params; + +dev_dbg (dai->dev,"%s: %s\n" , __func__, dai->name); +snd_hdac_stream_release (azx_dev); + dma_params = (struct soc_hda_dma_params *) +snd_soc_dai_get_dma_data (dai, substream); +kfree (dma_params); +} + +static int soc_hda_pcm_hw_free (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct hdac_bus *chip =dev_get_drvdata (dai->dev); +struct hdac_stream *azx_dev =get_azx_dev (substream); + +dev_dbg (dai->dev,"%s: %s\n" , __func__, dai->name); + +snd_hdac_stream_cleanup (azx_dev); + + azx_dev->prepared =0 ; + +return substream_free_pages (chip, substream); +} + +static struct snd_soc_dai_ops hda_pcm_dai_ops = { + .startup = soc_hda_pcm_open, + .shutdown = soc_hda_pcm_close, + .prepare = soc_hda_pcm_prepare, + .hw_params = soc_hda_pcm_hw_params, + .hw_free = soc_hda_pcm_hw_free, +}; + +static struct snd_soc_dai_driver soc_hda_platform_dai[] = { +{ + .name ="System Pin" , + .ops = &hda_pcm_dai_ops, + .playback = { + .stream_name ="System Playback" , + .channels_min =2 , + .channels_max =2 , + .rates =SNDRV_PCM_RATE_48000 , + .formats =SNDRV_PCM_FMTBIT_S16_LE , + }, + .capture = { + .stream_name ="System Capture" , + .channels_min =1 , + .channels_max =2 , + .rates =SNDRV_PCM_RATE_48000 , + .formats =SNDRV_PCM_FMTBIT_S16_LE , + }, +}, +}; + +static int soc_hda_platform_open (struct snd_pcm_substream *substream) +{ +struct snd_pcm_runtime *runtime; +struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_dai_link *dai_link = rtd->dai_link; + +dev_dbg (rtd->cpu_dai->dev,"In %s:%s\n" , __func__, + dai_link->cpu_dai_name); + + runtime = substream->runtime; +snd_soc_set_runtime_hwparams (substream, &azx_pcm_hw); +return 0 ; +} + +static int soc_hda_platform_pcm_trigger (struct snd_pcm_substream *substream, +int cmd) +{ +struct hdac_bus *chip =get_chip_ctx (substream); +struct hdac_stream *azx_dev; +struct snd_pcm_substream *s; +int rstart =0 , start, nsync =0 , sbits =0 ; +unsigned long cookie; + + azx_dev =get_azx_dev (substream); + +dev_dbg (chip->dev,"In %s cmd=%d\n" , __func__, cmd); + +if (!azx_dev->prepared) +return -EPIPE ; + +switch (cmd) { +case SNDRV_PCM_TRIGGER_START : + rstart =1 ; +case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : +case SNDRV_PCM_TRIGGER_RESUME : + start =1 ; +break ; +case SNDRV_PCM_TRIGGER_PAUSE_PUSH : +case SNDRV_PCM_TRIGGER_SUSPEND : +case SNDRV_PCM_TRIGGER_STOP : + start =0 ; +break ; +default : +return -EINVAL ; + } + +snd_pcm_group_for_each_entry (s, substream) { +if (s->pcm->card != substream->pcm->card) +continue ; + azx_dev =get_azx_dev (s); + sbits |=1 << azx_dev->index; + nsync++; +snd_pcm_trigger_done (s, substream); + } + +spin_lock_irqsave (&chip->reg_lock, cookie); + +/* first, set SYNC bits of corresponding streams */ +snd_hdac_stream_sync_trigger (azx_dev, start, sbits,0 ); + +snd_pcm_group_for_each_entry (s, substream) { +if (s->pcm->card != substream->pcm->card) +continue ; + azx_dev =get_azx_dev (s); +if (start) +snd_hdac_stream_start (azx_dev, rstart); +else +snd_hdac_stream_clear (azx_dev); + } +spin_unlock_irqrestore (&chip->reg_lock, cookie); +snd_hdac_stream_sync (azx_dev, start, sbits); +spin_lock_irqsave (&chip->reg_lock, cookie); + +/* reset SYNC bits */ +snd_hdac_stream_sync_trigger (azx_dev, start, sbits,0 ); + +if (start) +snd_hdac_stream_timecounter_init (azx_dev, sbits); +spin_unlock_irqrestore (&chip->reg_lock, cookie); +return 0 ; +} + +unsigned int azx_get_position (struct hdac_stream *azx_dev,int codec_delay) +{ +struct snd_pcm_substream *substream = azx_dev->substream; +struct hdac_bus *hbus =get_chip_ctx (substream); +unsigned int pos; +int stream = substream->stream; +int delay =0 ; + +/* use the position buffer as default */ + pos =snd_hdac_bus_get_pos_posbuf (hbus, azx_dev); + +if (pos >= azx_dev->bufsize) + pos =0 ; + +if (substream->runtime) { +if (hbus->get_delay[stream]) + delay += hbus->get_delay[stream](hbus, azx_dev, pos); + delay += codec_delay; + substream->runtime->delay += delay; + } + +return pos; +} + +static snd_pcm_uframes_t soc_hda_platform_pcm_pointer + (struct snd_pcm_substream *substream) +{ +struct hdac_stream *azx_dev =get_azx_dev (substream); + +return bytes_to_frames (substream->runtime, +azx_get_position (azx_dev,0 )); +} + +static int soc_hda_platform_pcm_mmap (struct snd_pcm_substream *substream, +struct vm_area_struct *area) +{ +return snd_pcm_lib_default_mmap (substream, area); +} + +static u64 soc_azx_adjust_codec_delay (struct snd_pcm_substream *substream, +u64 nsec) +{ +struct snd_soc_pcm_runtime *rtd =snd_pcm_substream_chip (substream); +struct snd_soc_dai *codec_dai = rtd->codec_dai; +u64 codec_frames, codec_nsecs; + +if (!codec_dai->driver->ops->delay) +return nsec; + + codec_frames = codec_dai->driver->ops->delay (substream, codec_dai); + codec_nsecs =div_u64 (codec_frames *1000000000LL , + substream->runtime->rate); + +if (substream->stream ==SNDRV_PCM_STREAM_CAPTURE ) +return nsec + codec_nsecs; + +return (nsec > codec_nsecs) ? nsec - codec_nsecs :0 ; +} + +static int soc_hda_get_time_info (struct snd_pcm_substream *substream, +struct timespec *system_ts,struct timespec *audio_ts, +struct snd_pcm_audio_tstamp_config *audio_tstamp_config, +struct snd_pcm_audio_tstamp_report *audio_tstamp_report) +{ +struct hdac_stream *azx_dev =get_azx_dev (substream); +u64 nsec; + +if ((substream->runtime->hw.info &SNDRV_PCM_INFO_HAS_LINK_ATIME ) && + (audio_tstamp_config->type_requested ==SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK )) { + +snd_pcm_gettime (substream->runtime, system_ts); + + nsec =timecounter_read (&azx_dev->tc); + nsec =div_u64 (nsec,3 );/* can be optimized */ +if (audio_tstamp_config->report_delay) + nsec =soc_azx_adjust_codec_delay (substream, nsec); + + *audio_ts =ns_to_timespec (nsec); + + audio_tstamp_report->actual_type =SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK ; + audio_tstamp_report->accuracy_report =1 ;/* rest of struct is valid */ + audio_tstamp_report->accuracy =42 ;/* 24MHzWallClk == 42ns resolution */ + + }else + audio_tstamp_report->actual_type =SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT ; + +return 0 ; +} + +static struct snd_pcm_ops soc_hda_platform_ops = { + .open = soc_hda_platform_open, + .ioctl = snd_pcm_lib_ioctl, + .trigger = soc_hda_platform_pcm_trigger, + .pointer = soc_hda_platform_pcm_pointer, + .get_time_info = soc_hda_get_time_info, + .mmap = soc_hda_platform_pcm_mmap, + .page = snd_pcm_sgbuf_ops_page, +}; + +static void soc_hda_pcm_free (struct snd_pcm *pcm) +{ +snd_pcm_lib_preallocate_free_for_all (pcm); +} + +#define MAX_PREALLOC_SIZE (32 * 1024 * 1024) + +static int soc_hda_pcm_new (struct snd_soc_pcm_runtime *rtd) +{ +struct snd_soc_dai *dai = rtd->cpu_dai; +struct hdac_bus *chip =dev_get_drvdata (dai->dev); +struct snd_pcm *pcm = rtd->pcm; +unsigned int size; +int retval =0 ; +struct soc_hda_skl *hda = + container_of(chip, struct soc_hda_skl, chip); + +dev_dbg (chip->dev,"In %s\n" , __func__); +if (dai->driver->playback.channels_min || + dai->driver->capture.channels_min) { +/* buffer pre-allocation */ + size =CONFIG_SND_HDA_PREALLOC_SIZE *1024 ; +if (size >MAX_PREALLOC_SIZE ) + size =MAX_PREALLOC_SIZE ; + retval =snd_pcm_lib_preallocate_pages_for_all (pcm, +SNDRV_DMA_TYPE_DEV_SG , +snd_dma_pci_data (hda->pci), + size,MAX_PREALLOC_SIZE ); +if (retval) { +dev_err (chip->dev,"dma buffer allocationf fail\n" ); +return retval; + } + } +return retval; +} + +static struct snd_soc_platform_driver soc_hda_platform_drv = { + .ops = &soc_hda_platform_ops, + .pcm_new = soc_hda_pcm_new, + .pcm_free = soc_hda_pcm_free, +}; + +static const struct snd_soc_component_driver soc_hda_component = { + .name ="pcm" , +}; + +int soc_hda_platform_register (struct device *dev) +{ +int ret =0 ; + + ret =snd_soc_register_platform (dev, + &soc_hda_platform_drv); +if (ret) { +dev_err (dev,"soc platform registration failed\n" ); +return ret; + } + ret =snd_soc_register_component (dev, &soc_hda_component, + soc_hda_platform_dai, +ARRAY_SIZE (soc_hda_platform_dai)); +if (ret) { +dev_err (dev,"soc component registration failed\n" ); +snd_soc_unregister_platform (dev); + } + +dev_dbg (dev,"In%s platform registration completed\n" , __func__); +return ret; + +} + +int soc_hda_platform_unregister (struct device *dev) +{ +snd_soc_unregister_component (dev); +snd_soc_unregister_platform (dev); +return 0 ; +}
Signature · 1 line
1.9.0
RFC 9/11 ALSA: hda - moved interrupt handler to controller library
In reply to Subhransu S. PrustyFrom: Jeeja KP <[email protected]>
This will be used by controller legacy and SKL driver
--- include/sound/hdaudio.h | 1 + sound/hda/hdac_controller.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+)
include/sound/hdaudio.h +1 -0
@@ -293,6 +293,7 @@ void snd_hdac_bus_update_rirb(struct hdac_bus *bus);void snd_hdac_bus_handle_stream_irq (struct hdac_bus *bus,unsigned int status,void (*ack)(struct hdac_bus *,struct hdac_stream *)); +irqreturn_t snd_hdac_bus_interrupt (int irq,void *dev_id);int snd_hdac_bus_alloc_stream_pages (struct hdac_bus *bus);void snd_hdac_bus_free_stream_pages (struct hdac_bus *bus);
sound/hda/hdac_controller.c +24 -0
@@ -5,6 +5,7 @@#include <linux/kernel.h> #include <linux/delay.h> #include <linux/export.h> +#include <linux/pm_runtime.h> #include <sound/core.h> #include <sound/hdaudio.h> #include <sound/hda_registers.h>
@@ -381,6 +382,29 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_stop_chip);/* * interrupt handler */ +irqreturn_t snd_hdac_bus_interrupt (int irq,void *dev_id) +{ +struct hdac_bus *chip = dev_id; +u32 status; + +#ifdef CONFIG_PM +if (!pm_runtime_active (chip->dev)) +return IRQ_NONE ; +#endif + +spin_lock (&chip->reg_lock); + + status =azx_readl (chip,INTSTS ); +if (status ==0 || status ==0xffffffff ) { +spin_unlock (&chip->reg_lock); +return IRQ_NONE ; + } +spin_unlock (&chip->reg_lock); + +return IRQ_WAKE_THREAD ; +} +EXPORT_SYMBOL_GPL (snd_hdac_bus_interrupt); +void snd_hdac_bus_handle_stream_irq (struct hdac_bus *bus,unsigned int status,void (*ack)(struct hdac_bus *,struct hdac_stream *))
Signature · 1 line
1.9.0
Re: [RFC 09/11] ALSA: hda - moved interrupt handler to controller library
At Sun, 12 Apr 2015 18:06:16 +0530,
Quoted 53 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
This will be used by controller legacy and SKL driver
Signed-off-by Jeeja KP <[email protected]>Signed-off-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- include/sound/hdaudio.h | 1 + sound/hda/hdac_controller.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+)include/sound/hdaudio.h +1
-0@@ -293,6 +293,7 @@ void snd_hdac_bus_update_rirb(struct hdac_bus *bus);void snd_hdac_bus_handle_stream_irq (struct hdac_bus *bus,unsigned int status,void (*ack)(struct hdac_bus *,struct hdac_stream *)); +irqreturn_t snd_hdac_bus_interrupt (int irq,void *dev_id);int snd_hdac_bus_alloc_stream_pages (struct hdac_bus *bus);void snd_hdac_bus_free_stream_pages (struct hdac_bus *bus);sound/hda/hdac_controller.c +13
-0@@ -5,6 +5,7 @@#include <linux/kernel.h> #include <linux/delay.h> #include <linux/export.h> +#include <linux/pm_runtime.h> #include <sound/core.h> #include <sound/hdaudio.h> #include <sound/hda_registers.h> @@ -381,6 +382,29 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_stop_chip);/* * interrupt handler */ +irqreturn_t snd_hdac_bus_interrupt (int irq,void *dev_id) +{ +struct hdac_bus *chip = dev_id; +u32 status; + +#ifdef CONFIG_PM +if (!pm_runtime_active (chip->dev)) +return IRQ_NONE ; +#endif + +spin_lock (&chip->reg_lock); +
sound/hda/hdac_controller.c EXPORT_SYMBOL_GPL(snd_hdac_bus_stop_chip); · line 406
Quoted 10 lines
sound/hda/hdac_controller.c +10
-0+ status =azx_readl (chip,INTSTS ); +if (status ==0 || status ==0xffffffff ) { +spin_unlock (&chip->reg_lock); +return IRQ_NONE ; + } +spin_unlock (&chip->reg_lock); + +return IRQ_WAKE_THREAD ; +} +EXPORT_SYMBOL_GPL (snd_hdac_bus_interrupt);
Again, this is specific to ASoC driver, so let's keep it local.
thanks,
Takashi
Re: [RFC 09/11] ALSA: hda - moved interrupt handler to controller library
Quoted 59 lines · Takashi Iwai
At Sun, 12 Apr 2015 18:06:16 +0530,
Quoted 57 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
This will be used by controller legacy and SKL driver
Signed-off-by Jeeja KP <[email protected]>Signed-off-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- include/sound/hdaudio.h | 1 + sound/hda/hdac_controller.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+)include/sound/hdaudio.h +1
-0@@ -293,6 +293,7 @@ void snd_hdac_bus_update_rirb(struct hdac_bus *bus);void snd_hdac_bus_handle_stream_irq (struct hdac_bus *bus,unsigned int status,void (*ack)(struct hdac_bus *,struct hdac_stream *)); +irqreturn_t snd_hdac_bus_interrupt (int irq,void *dev_id);int snd_hdac_bus_alloc_stream_pages (struct hdac_bus *bus);void snd_hdac_bus_free_stream_pages (struct hdac_bus *bus);sound/hda/hdac_controller.c +17
-0@@ -5,6 +5,7 @@#include <linux/kernel.h> #include <linux/delay.h> #include <linux/export.h> +#include <linux/pm_runtime.h> #include <sound/core.h> #include <sound/hdaudio.h> #include <sound/hda_registers.h> @@ -381,6 +382,29 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_stop_chip);/* * interrupt handler */ +irqreturn_t snd_hdac_bus_interrupt (int irq,void *dev_id) +{ +struct hdac_bus *chip = dev_id; +u32 status; + +#ifdef CONFIG_PM +if (!pm_runtime_active (chip->dev)) +return IRQ_NONE ; +#endif + +spin_lock (&chip->reg_lock); + + status =azx_readl (chip,INTSTS ); +if (status ==0 || status ==0xffffffff ) { +spin_unlock (&chip->reg_lock); +return IRQ_NONE ;
Quoted 8 lines
sound/hda/hdac_controller.c EXPORT_SYMBOL_GPL(snd_hdac_bus_stop_chip); · line 406
Quoted 6 lines
sound/hda/hdac_controller.c +6
-0+ } +spin_unlock (&chip->reg_lock); + +return IRQ_WAKE_THREAD ; +} +EXPORT_SYMBOL_GPL (snd_hdac_bus_interrupt);Again, this is specific to ASoC driver, so let's keep it local.
Hmmm, but most of this is based on HDA spec and not doing much wrt driver. Moving to ASoC is fine too... WIll move
Signature · 1 line
~Vinod
Re: [RFC 09/11] ALSA: hda - moved interrupt handler to controller library
At Tue, 14 Apr 2015 10:13:56 +0530,
Quoted 69 lines · Vinod Koul
Quoted 59 lines · Takashi Iwai
At Sun, 12 Apr 2015 18:06:16 +0530,
Quoted 57 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
This will be used by controller legacy and SKL driver
Signed-off-by Jeeja KP <[email protected]>Signed-off-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- include/sound/hdaudio.h | 1 + sound/hda/hdac_controller.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+)include/sound/hdaudio.h +1
-0@@ -293,6 +293,7 @@ void snd_hdac_bus_update_rirb(struct hdac_bus *bus);void snd_hdac_bus_handle_stream_irq (struct hdac_bus *bus,unsigned int status,void (*ack)(struct hdac_bus *,struct hdac_stream *)); +irqreturn_t snd_hdac_bus_interrupt (int irq,void *dev_id);int snd_hdac_bus_alloc_stream_pages (struct hdac_bus *bus);void snd_hdac_bus_free_stream_pages (struct hdac_bus *bus);sound/hda/hdac_controller.c +17
-0@@ -5,6 +5,7 @@#include <linux/kernel.h> #include <linux/delay.h> #include <linux/export.h> +#include <linux/pm_runtime.h> #include <sound/core.h> #include <sound/hdaudio.h> #include <sound/hda_registers.h> @@ -381,6 +382,29 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_stop_chip);/* * interrupt handler */ +irqreturn_t snd_hdac_bus_interrupt (int irq,void *dev_id) +{ +struct hdac_bus *chip = dev_id; +u32 status; + +#ifdef CONFIG_PM +if (!pm_runtime_active (chip->dev)) +return IRQ_NONE ; +#endif + +spin_lock (&chip->reg_lock); + + status =azx_readl (chip,INTSTS ); +if (status ==0 || status ==0xffffffff ) { +spin_unlock (&chip->reg_lock); +return IRQ_NONE ;Quoted 8 lines
sound/hda/hdac_controller.c EXPORT_SYMBOL_GPL(snd_hdac_bus_stop_chip); · line 406
Quoted 6 lines
sound/hda/hdac_controller.c +6
-0+ } +spin_unlock (&chip->reg_lock); + +return IRQ_WAKE_THREAD ; +} +EXPORT_SYMBOL_GPL (snd_hdac_bus_interrupt);Again, this is specific to ASoC driver, so let's keep it local.
Quoted 2 lines
Hmmm, but most of this is based on HDA spec and not doing much wrt driver. Moving to ASoC is fine too... WIll move
The assumption of threaded IRQ alone is driver-specific :)
Takashi
RFC 10/11 ASoC: hda - add Skylake HD audio driver
In reply to Subhransu S. PrustyFrom: Jeeja KP <[email protected]>
Add ASoC Skylake HD audio controller driver
--- include/sound/hdaudio.h | 11 + sound/soc/hda/hda_skl.c | 829 ++++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/hda/hda_skl.h | 49 +++ 3 files changed, 889 insertions(+) create mode 100644 sound/soc/hda/hda_skl.c create mode 100644 sound/soc/hda/hda_skl.h
include/sound/hdaudio.h +11 -0
@@ -197,6 +197,11 @@ struct hda_rb {u32 res[HDA_MAX_CODECS ];/* last read value */ }; +typedef unsigned int (*hdac_stream_get_pos_callback_t )(struct hdac_bus *, +struct hdac_stream *); +typedef int (*hdac_stream_get_delay_callback_t )(struct hdac_bus *, +struct hdac_stream *,unsigned int pos); +struct hdac_bus {struct device *dev;const struct hdac_bus_ops *ops;
@@ -233,6 +238,10 @@ struct hdac_bus {struct snd_dma_buffer rb;struct snd_dma_buffer posbuf; +/* position adjustment callbacks */ +hdac_stream_get_pos_callback_t get_position[2 ]; +hdac_stream_get_delay_callback_t get_delay[2 ]; +/* hdac_stream linked list */ struct list_head stream_list;
@@ -330,6 +339,8 @@ struct hdac_stream { unsigned int opened:1; unsigned int running:1; + unsigned int prepared:1; + unsigned int irq_pending:1; unsigned int no_period_wakeup:1; unsigned int locked:1;
sound/soc/hda/hda_skl.c new file +829 -0
829 lines not on this page · raw message
sound/soc/hda/hda_skl.h new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
1.9.0
Re: [RFC 10/11] ASoC: hda - add Skylake HD audio driver
At Sun, 12 Apr 2015 18:06:17 +0530,
Quoted 33 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
Add ASoC Skylake HD audio controller driver
Signed-off-by Jeeja KP <[email protected]>Signed-off-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- include/sound/hdaudio.h | 11 + sound/soc/hda/hda_skl.c | 829 ++++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/hda/hda_skl.h | 49 +++ 3 files changed, 889 insertions(+) create mode 100644 sound/soc/hda/hda_skl.c create mode 100644 sound/soc/hda/hda_skl.hinclude/sound/hdaudio.h +5
-0@@ -197,6 +197,11 @@ struct hda_rb {u32 res[HDA_MAX_CODECS ];/* last read value */ }; +typedef unsigned int (*hdac_stream_get_pos_callback_t )(struct hdac_bus *, +struct hdac_stream *); +typedef int (*hdac_stream_get_delay_callback_t )(struct hdac_bus *, +struct hdac_stream *,unsigned int pos); +struct hdac_bus {struct device *dev;const struct hdac_bus_ops *ops;
include/sound/hdaudio.h struct hdac_bus { · line 243
Quoted 6 lines
include/sound/hdaudio.h +3
-0@@ -233,6 +238,10 @@ struct hdac_bus {struct snd_dma_buffer rb;struct snd_dma_buffer posbuf; +/* position adjustment callbacks */ +hdac_stream_get_pos_callback_t get_position[2 ]; +hdac_stream_get_delay_callback_t get_delay[2 ];
So, do you still need the dynamic switch of get_position and get_delay functions on SKL? These are basically for old platforms that have no position buffer support or unstable reads.
Otherwise you can use always LPIB and position buffers for position and delay calculations. That's why I didn't put them at the first place.
include/sound/hdaudio.h struct hdac_stream { · line 343
Quoted 10 lines
include/sound/hdaudio.h +3
-0+/* hdac_stream linked list */ struct list_head stream_list;@@ -330,6 +339,8 @@ struct hdac_stream { unsigned int opened:1; unsigned int running:1; + unsigned int prepared:1; + unsigned int irq_pending:1;
The irq_pending is also another question. This was a workaround, and whether it's still needed for the modern chips is not sure.
thanks,
Takashi
Re: [RFC 10/11] ASoC: hda - add Skylake HD audio driver
Quoted 46 lines · Takashi Iwai
At Sun, 12 Apr 2015 18:06:17 +0530,
Quoted 33 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
Add ASoC Skylake HD audio controller driver
Signed-off-by Jeeja KP <[email protected]>Signed-off-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- include/sound/hdaudio.h | 11 + sound/soc/hda/hda_skl.c | 829 ++++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/hda/hda_skl.h | 49 +++ 3 files changed, 889 insertions(+) create mode 100644 sound/soc/hda/hda_skl.c create mode 100644 sound/soc/hda/hda_skl.hinclude/sound/hdaudio.h +5
-0@@ -197,6 +197,11 @@ struct hda_rb {u32 res[HDA_MAX_CODECS ];/* last read value */ }; +typedef unsigned int (*hdac_stream_get_pos_callback_t )(struct hdac_bus *, +struct hdac_stream *); +typedef int (*hdac_stream_get_delay_callback_t )(struct hdac_bus *, +struct hdac_stream *,unsigned int pos); +struct hdac_bus {struct device *dev;const struct hdac_bus_ops *ops;include/sound/hdaudio.h struct hdac_bus { · line 243
Quoted 6 lines
include/sound/hdaudio.h +3
-0@@ -233,6 +238,10 @@ struct hdac_bus {struct snd_dma_buffer rb;struct snd_dma_buffer posbuf; +/* position adjustment callbacks */ +hdac_stream_get_pos_callback_t get_position[2 ]; +hdac_stream_get_delay_callback_t get_delay[2 ];So, do you still need the dynamic switch of
get_positionandget_delayfunctions on SKL? These are basically for old platforms that have no position buffer support or unstable reads.
Quoted 3 lines
Otherwise you can use always LPIB and position buffers for position and delay calculations. That's why I didn't put them at the first place.
Jeeja tested this last evening so we dont need this on SKL and will remove, and you were right :)
Quoted 7 lines
Quoted 7 lines
include/sound/hdaudio.h +1
-0+/* hdac_stream linked list */ struct list_head stream_list;@@ -330,6 +339,8 @@ struct hdac_stream {
Quoted 7 lines
include/sound/hdaudio.h struct hdac_stream { · line 343
Quoted 4 lines
include/sound/hdaudio.h +2
-0unsigned int opened:1; unsigned int running:1; + unsigned int prepared:1; + unsigned int irq_pending:1;The
irq_pendingis also another question. This was a workaround, and whether it's still needed for the modern chips is not sure.
nope, will drop this patch
Signature · 1 line
~Vinod
RFC 11/11 ASoC: hda - enable ASoC Skylake HD audio driver
In reply to Subhransu S. PrustyFrom: Jeeja KP <[email protected]>
Add makefile and Kconfig to enable Skylake
HD audio driver
--- sound/soc/Kconfig | 3 ++- sound/soc/Makefile | 1 + sound/soc/hda/Kconfig | 29 +++++++++++++++++++++++++++++ sound/soc/hda/Makefile | 6 ++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 sound/soc/hda/Kconfig create mode 100644 sound/soc/hda/Makefile
sound/soc/Kconfig +2 -1
@@ -14,7 +14,7 @@ menuconfig SND_SOC If you want ASoC support, you should say Y here and also to the specific driver for your SoC platform below. - + ASoC provides power efficient ALSA support for embedded battery powered SoC based systems like PDA's, Phones and Personal Media Players.
@@ -40,6 +40,7 @@ source "sound/soc/cirrus/Kconfig" source "sound/soc/davinci/Kconfig" source "sound/soc/dwc/Kconfig" source "sound/soc/fsl/Kconfig" +source "sound/soc/hda/Kconfig" source "sound/soc/jz4740/Kconfig" source "sound/soc/nuc900/Kconfig" source "sound/soc/omap/Kconfig"
sound/soc/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_SND_SOC) += cirrus/ obj-$(CONFIG_SND_SOC) += davinci/ obj-$(CONFIG_SND_SOC) += dwc/ obj-$(CONFIG_SND_SOC) += fsl/ +obj-$(CONFIG_SND_SOC) += hda/ obj-$(CONFIG_SND_SOC) += jz4740/ obj-$(CONFIG_SND_SOC) += intel/ obj-$(CONFIG_SND_SOC) += mxs/
sound/soc/hda/Kconfig new file +29 -0
@@ -0,0 +1,29 @@ +menu "SKL-HD-Audio" + +config SND_SOC_HDA + tristate + select SND_HDA_CORE + +if SND_SOC_HDA + +config SND_HDA_PREALLOC_SIZE + int "Pre-allocated buffer size for HD-audio driver" + range 0 32768 + default 64 + help + Specifies the default pre-allocated buffer-size in kB for the + HD-audio driver. A larger buffer (e.g. 2048) is preferred + for systems using PulseAudio. The default 64 is chosen just + for compatibility reasons. +endif + +config SND_SOC_HDA_SKL + tristate "ASoC Intel HD Audio" + select SND_SOC_HDA + help + Say Y here to include support for ASoC Intel "High Definition + Audio" (Azalia) and its compatible devices. + + To compile this driver as a module, choose M here: the module + will be called snd-soc-hda-skl. +endmenu
sound/soc/hda/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +ccflags-y += -Werror + +snd-soc-hda-skl-objs := hda_skl.o hda_skl_pcm.o + +# common driver +obj-$(CONFIG_SND_SOC_HDA_SKL) += snd-soc-hda-skl.o
Signature · 1 line
1.9.0
Re: [RFC 11/11] ASoC: hda - enable ASoC Skylake HD audio driver
At Sun, 12 Apr 2015 18:06:18 +0530,
Quoted 57 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
Add makefile and
Kconfigto enable Skylake
HD audio driverSigned-off-by Jeeja KP <[email protected]>Signed-off-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- sound/soc/Kconfig | 3 ++- sound/soc/Makefile | 1 + sound/soc/hda/Kconfig | 29 +++++++++++++++++++++++++++++ sound/soc/hda/Makefile | 6 ++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 sound/soc/hda/Kconfig create mode 100644 sound/soc/hda/Makefilesound/soc/Kconfig +2
-1@@ -14,7 +14,7 @@ menuconfig SND_SOC If you want ASoC support, you should say Y here and also to the specific driver for your SoC platform below. - + ASoC provides power efficient ALSA support for embedded battery powered SoC based systems like PDA's, Phones and Personal Media Players.@@ -40,6 +40,7 @@ source "sound/soc/cirrus/Kconfig" source "sound/soc/davinci/Kconfig" source "sound/soc/dwc/Kconfig" source "sound/soc/fsl/Kconfig" +source "sound/soc/hda/Kconfig" source "sound/soc/jz4740/Kconfig" source "sound/soc/nuc900/Kconfig" source "sound/soc/omap/Kconfig"sound/soc/Makefile +1
-0@@ -21,6 +21,7 @@ obj-$(CONFIG_SND_SOC) += cirrus/ obj-$(CONFIG_SND_SOC) += davinci/ obj-$(CONFIG_SND_SOC) += dwc/ obj-$(CONFIG_SND_SOC) += fsl/ +obj-$(CONFIG_SND_SOC) += hda/ obj-$(CONFIG_SND_SOC) += jz4740/ obj-$(CONFIG_SND_SOC) += intel/ obj-$(CONFIG_SND_SOC) += mxs/sound/soc/hda/Kconfig new file +0
-0
sound/soc/hda/Kconfig line 9
Quoted 9 lines
sound/soc/hda/Kconfig new file +9
-0@@ -0,0 +1,29 @@ +menu "SKL-HD-Audio" + +config SND_SOC_HDA + tristate + select SND_HDA_CORE + +if SND_SOC_HDA + +config SND_HDA_PREALLOC_SIZE
The symbol conflicts.
Takashi
Re: [RFC 11/11] ASoC: hda - enable ASoC Skylake HD audio driver
Quoted 19 lines · Takashi Iwai
At Sun, 12 Apr 2015 18:06:18 +0530,
Quoted 6 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
index 0000000..1711126sound/soc/hda/Kconfig line 9
Quoted 9 lines
sound/soc/hda/Kconfig new file +9
-0@@ -0,0 +1,29 @@ +menu "SKL-HD-Audio" + +config SND_SOC_HDA + tristate + select SND_HDA_CORE + +if SND_SOC_HDA + +config SND_HDA_PREALLOC_SIZEThe symbol conflicts.
Oops, any guidance for this name... ASOC_HDA_PREALLOC_SIZE or SND_SOC_SND_HDA_PREALLOC_SIZE (but its too long)
Or move this up to hdac and be used by both?
Signature · 1 line
~Vinod
Re: [RFC 11/11] ASoC: hda - enable ASoC Skylake HD audio driver
At Tue, 14 Apr 2015 10:16:22 +0530,
Quoted 21 lines · Vinod Koul
Quoted 19 lines · Takashi Iwai
At Sun, 12 Apr 2015 18:06:18 +0530,
Quoted 6 lines · Subhransu S. Prusty
From: Jeeja KP <[email protected]>
index 0000000..1711126sound/soc/hda/Kconfig line 9
Quoted 9 lines
sound/soc/hda/Kconfig new file +9
-0@@ -0,0 +1,29 @@ +menu "SKL-HD-Audio" + +config SND_SOC_HDA + tristate + select SND_HDA_CORE + +if SND_SOC_HDA + +config SND_HDA_PREALLOC_SIZEThe symbol conflicts.
Quoted 2 lines
Oops, any guidance for this name...
ASOC_HDA_PREALLOC_SIZEorSND_SOC_SND_HDA_PREALLOC_SIZE(but its too long)
The latter or...
Quoted 1 line
Or move this up to hdac and be used by both?
... this. I don't mind both.
Takashi