ALSA - hda: Add support for link audio time reporting
Subsystems (3)
v3 cover ALSA - hda: Add support for link audio time reporting
Skylake onwards we support GTS capability and thus can report audio link time. This series adds support for parsing the capability and then reports link time.
The parsing of caps is made common and moved up from extended hda to hdac. The SKL driver and hdac extended core has been updated for this.
Mark,
The update of the driver needs to update Skl driver, so if you can
ACK the 2nd patch, it can go along with extended audio change thru ALSA tree.
Changes in v3:
moved extended hda to hdac
update SKL drv to use new hdac caps
update patchset for HDA drv to use new caps parsing
Guneshwor Singh (2):
ALSA - hda: Add support for parsing new HDA capabilities ALSA - hda: Add support for link audio time reporting
Vinod Koul (3):
ALSA: hda - move bus_parse_capabilities to core
ALSA: convert users to core bus_parse_capabilities ALSA - Ext hda: remove bus_parse_capabilities
include/sound/hda_register.h | 36 ++++++ include/sound/hdaudio.h | 13 +++ include/sound/hdaudio_ext.h | 12 -- sound/hda/ext/hdac_ext_controller.c | 91 ++------------- sound/hda/ext/hdac_ext_stream.c | 46 ++++---- sound/hda/hdac_controller.c | 76 +++++++++++++ sound/pci/hda/hda_controller.c | 200 ++++++++++++++++++++++++++++++++- sound/pci/hda/hda_controller.h | 3 + sound/pci/hda/hda_intel.c | 16 +++ sound/soc/intel/skylake/skl-messages.c | 4 +- sound/soc/intel/skylake/skl-pcm.c | 8 +- sound/soc/intel/skylake/skl.c | 6 +- 12 files changed, 383 insertions(+), 128 deletions(-)
Signature · 1 line
1.9.1
PATCH v3 1/5 ALSA: hda - move bus_parse_capabilities to core
HDA capability introduced recently are moved to hdac core so that it can be used by legacy driver as well. Also move the capability pointers up to hdac_bus object.
--- include/sound/hdaudio.h | 13 ++++++++ sound/hda/hdac_controller.c | 76 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+)
include/sound/hdaudio.h +13 -0
@@ -245,6 +245,12 @@ struct hdac_rb {/* * HD-audio bus base driver +* +* @ppcap: pp capabilities pointer +* @spbcap: SPIB capabilities pointer +* @mlcap: MultiLink capabilities pointer +* @gtscap: gts capabilities pointer +* @drsmcap: dma resume capabilities pointer */ struct hdac_bus {struct device *dev;
@@ -256,6 +262,12 @@ struct hdac_bus {void __iomem *remap_addr;int irq; +void __iomem *ppcap; +void __iomem *spbcap; +void __iomem *mlcap; +void __iomem *gtscap; +void __iomem *drsmcap; +/* codec linked list */ struct list_head codec_list;unsigned int num_codecs;
@@ -335,6 +347,7 @@ static inline void snd_hdac_codec_link_down(struct hdac_device *codec)int snd_hdac_bus_send_cmd (struct hdac_bus *bus,unsigned int val);int snd_hdac_bus_get_response (struct hdac_bus *bus,unsigned int addr,unsigned int *res); +int snd_hdac_bus_parse_capabilities (struct hdac_bus *bus);int snd_hdac_link_power (struct hdac_device *codec,bool enable);bool snd_hdac_bus_init_chip (struct hdac_bus *bus,bool full_reset);
sound/hda/hdac_controller.c +76 -0
82 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v3 1/5] ALSA: hda - move bus_parse_capabilities to core
Quoted 6 lines · Vinod Koul
HDA capability introduced recently are moved to hdac core so that it can be used by legacy driver as well. Also move the capability pointers up to
hdac_busobject.Signed-off-by Vinod Koul <[email protected]>
The patch looks almost good, but just minor nitpicking:
Quoted 4 lines
sound/hda/hdac_controller.c +4
-0+int snd_hdac_bus_parse_capabilities (struct hdac_bus *bus) +{ +unsigned int cur_cap; +unsigned int offset;
sound/hda/hdac_controller.c int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr, · line 278
Quoted 10 lines
sound/hda/hdac_controller.c +10
-0+unsigned int counter =0 ; + + offset =snd_hdac_chip_readl (bus,LLCH ); + +/* Lets walk the linked capabilities list */ + do { + cur_cap = _snd_hdac_chip_read(l, bus, offset); + + dev_dbg(bus->dev, "Capability version: 0x%x\n", + ((cur_cap & AZX_CAP_HDR_VER_MASK) >> AZX_CAP_HDR_VER_OFF));
Too much indentation. Also the parentheses are superfluous (unlike below).
sound/hda/hdac_controller.c int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr, · line 281
Quoted 3 lines
sound/hda/hdac_controller.c +3
-0+ +dev_dbg (bus->dev,"HDA capability ID: 0x%x\n" , + (cur_cap &AZX_CAP_HDR_ID_MASK ) >>AZX_CAP_HDR_ID_OFF );
Too much indentation.
Quoted 32 lines
sound/hda/hdac_controller.c +32
-0+switch ((cur_cap &AZX_CAP_HDR_ID_MASK ) >>AZX_CAP_HDR_ID_OFF ) { +case AZX_ML_CAP_ID : +dev_dbg (bus->dev,"Found ML capability\n" ); + bus->mlcap = bus->remap_addr + offset; +break ; + +case AZX_GTS_CAP_ID : +dev_dbg (bus->dev,"Found GTS capability offset=%x\n" , offset); + bus->gtscap = bus->remap_addr + offset; +break ; + +case AZX_PP_CAP_ID : +/* PP capability found, the Audio DSP is present */ +dev_dbg (bus->dev,"Found PP capability offset=%x\n" , offset); + bus->ppcap = bus->remap_addr + offset; +break ; + +case AZX_SPB_CAP_ID : +/* SPIB capability found, handler function */ +dev_dbg (bus->dev,"Found SPB capability\n" ); + bus->spbcap = bus->remap_addr + offset; +break ; + +case AZX_DRSM_CAP_ID : +/* DMA resume capability found, handler function */ +dev_dbg (bus->dev,"Found DRSM capability\n" ); + bus->drsmcap = bus->remap_addr + offset; +break ; + +default : +dev_dbg (bus->dev,"Unknown capability %d\n" , cur_cap); +break ;
sound/hda/hdac_controller.c int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr, · line 324
Quoted 10 lines
sound/hda/hdac_controller.c +10
-0+ } + + counter++; + +if (counter >HDAC_MAX_CAPS ) { +dev_err (bus->dev,"We exceeded HDAC capablities!!!\n" ); +break ; + } + +/* read the offset of next capabiity */
A typo.
thanks,
Takashi
Re: [PATCH v3 1/5] ALSA: hda - move bus_parse_capabilities to core
Quoted 5 lines · Takashi Iwai
sound/hda/hdac_controller.c int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr, · line 278
Quoted 2 lines
sound/hda/hdac_controller.c +2
-0+dev_dbg (bus->dev,"Capability version: 0x%x\n" , + ((cur_cap &AZX_CAP_HDR_VER_MASK ) >>AZX_CAP_HDR_VER_OFF ));Too much indentation. Also the parentheses are superfluous (unlike below).
Okay, I didn't modify this piece and copied. Will update this.
Quoted 6 lines
sound/hda/hdac_controller.c int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr, · line 281
Quoted 4 lines
sound/hda/hdac_controller.c +3
-0+ +dev_dbg (bus->dev,"HDA capability ID: 0x%x\n" , + (cur_cap &AZX_CAP_HDR_ID_MASK ) >>AZX_CAP_HDR_ID_OFF );Too much indentation.
ok
Quoted 3 lines
sound/hda/hdac_controller.c int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr, · line 324
Quoted 1 line
sound/hda/hdac_controller.c +1
-0+/* read the offset of next capabiity */ A typo.
ok
Signature · 1 line
~Vinod
PATCH v3 2/5 ALSA: convert users to core bus_parse_capabilities
In reply to Vinod KoulNow that we have the bus parse capabilities moved to core, we need to convert users.
The SKL driver and HDA extended lib needs to converted in single patch, otherwise we regress on the functionality.
--- sound/hda/ext/hdac_ext_controller.c | 16 ++++++------ sound/hda/ext/hdac_ext_stream.c | 46 +++++++++++++++++----------------- sound/soc/intel/skylake/skl-messages.c | 4 +-- sound/soc/intel/skylake/skl-pcm.c | 8 +++--- sound/soc/intel/skylake/skl.c | 6 ++--- 5 files changed, 40 insertions(+), 40 deletions(-)
sound/hda/ext/hdac_ext_controller.c +8 -8
@@ -118,15 +118,15 @@ void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus *ebus, bool enable) {struct hdac_bus *bus = &ebus->bus; -if (!ebus->ppcap) { +if (!bus->ppcap) {dev_err (bus->dev,"Address of PP capability is NULL" );return ; }if (enable) -snd_hdac_updatel (ebus->ppcap,AZX_REG_PP_PPCTL ,0 ,AZX_PPCTL_GPROCEN ); +snd_hdac_updatel (bus->ppcap,AZX_REG_PP_PPCTL ,0 ,AZX_PPCTL_GPROCEN );else -snd_hdac_updatel (ebus->ppcap,AZX_REG_PP_PPCTL ,AZX_PPCTL_GPROCEN ,0 ); +snd_hdac_updatel (bus->ppcap,AZX_REG_PP_PPCTL ,AZX_PPCTL_GPROCEN ,0 ); }EXPORT_SYMBOL_GPL (snd_hdac_ext_bus_ppcap_enable);
@@ -139,15 +139,15 @@ void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *ebus, bool enable) {struct hdac_bus *bus = &ebus->bus; -if (!ebus->ppcap) { +if (!bus->ppcap) {dev_err (bus->dev,"Address of PP capability is NULL\n" );return ; }if (enable) -snd_hdac_updatel (ebus->ppcap,AZX_REG_PP_PPCTL ,0 ,AZX_PPCTL_PIE ); +snd_hdac_updatel (bus->ppcap,AZX_REG_PP_PPCTL ,0 ,AZX_PPCTL_PIE );else -snd_hdac_updatel (ebus->ppcap,AZX_REG_PP_PPCTL ,AZX_PPCTL_PIE ,0 ); +snd_hdac_updatel (bus->ppcap,AZX_REG_PP_PPCTL ,AZX_PPCTL_PIE ,0 ); }EXPORT_SYMBOL_GPL (snd_hdac_ext_bus_ppcap_int_enable);
@@ -171,7 +171,7 @@ int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus *ebus)struct hdac_ext_link *hlink;struct hdac_bus *bus = &ebus->bus; - link_count =readl (ebus->mlcap +AZX_REG_ML_MLCD ) +1 ; + link_count =readl (bus->mlcap +AZX_REG_ML_MLCD ) +1 ;dev_dbg (bus->dev,"In %s Link count: %d\n" , __func__, link_count);
@@ -181,7 +181,7 @@ int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus *ebus)return -ENOMEM ; hlink->index = idx; hlink->bus = bus; - hlink->ml_addr = ebus->mlcap +AZX_ML_BASE + + hlink->ml_addr = bus->mlcap +AZX_ML_BASE + (AZX_ML_INTERVAL * idx); hlink->lcaps =readl (hlink->ml_addr +AZX_REG_ML_LCAP ); hlink->lsdiid =readw (hlink->ml_addr +AZX_REG_ML_LSDIID );
sound/hda/ext/hdac_ext_stream.c +23 -23
137 lines not on this page · raw message
sound/soc/intel/skylake/skl-messages.c +2 -2
@@ -296,7 +296,7 @@ int skl_suspend_dsp(struct skl *skl)int ret;/* if ppcap is not supported return 0 */ -if (!skl->ebus.ppcap) +if (!skl->ebus.bus.ppcap)return 0 ; ret =skl_dsp_sleep (ctx->dsp);
@@ -316,7 +316,7 @@ int skl_resume_dsp(struct skl *skl)int ret;/* if ppcap is not supported return 0 */ -if (!skl->ebus.ppcap) +if (!skl->ebus.bus.ppcap)return 0 ;/* enable ppcap interrupt */
sound/soc/intel/skylake/skl-pcm.c +4 -4
@@ -106,7 +106,7 @@ static void skl_set_pcm_constrains(struct hdac_ext_bus *ebus,static enum hdac_ext_stream_type skl_get_host_stream_type (struct hdac_ext_bus *ebus) { -if (ebus->ppcap) +if ((ebus_to_hbus (ebus))->ppcap)return HDAC_EXT_STREAM_TYPE_HOST ;else return HDAC_EXT_STREAM_TYPE_COUPLED ;
@@ -188,7 +188,7 @@ static int skl_get_format(struct snd_pcm_substream *substream,struct hdac_ext_bus *ebus =dev_get_drvdata (dai->dev);int format_val =0 ; -if (ebus->ppcap) { +if ((ebus_to_hbus (ebus))->ppcap) {struct snd_pcm_runtime *runtime = substream->runtime; format_val = snd_hdac_calc_stream_format(runtime->rate,
@@ -1020,7 +1020,7 @@ static int skl_platform_pcm_trigger(struct snd_pcm_substream *substream, {struct hdac_ext_bus *ebus =get_bus_ctx (substream); -if (!ebus->ppcap) +if ((ebus_to_hbus (ebus))->ppcap)return skl_coupled_trigger (substream, cmd);return 0 ;
@@ -1144,7 +1144,7 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform)struct skl *skl =ebus_to_skl (ebus);int ret; -if (ebus->ppcap) { +if ((ebus_to_hbus (ebus))->ppcap) { ret =skl_tplg_init (platform, ebus);if (ret <0 ) {dev_err (platform->dev,"Failed to init topology!\n" );
sound/soc/intel/skylake/skl.c +3 -3
@@ -587,7 +587,7 @@ static int skl_first_init(struct hdac_ext_bus *ebus)return -ENXIO ; } -snd_hdac_ext_bus_parse_capabilities (ebus); +snd_hdac_bus_parse_capabilities (bus);if (skl_acquire_irq (ebus,0 ) <0 )return -EBUSY ;
@@ -682,7 +682,7 @@ static int skl_probe(struct pci_dev *pci, skl_dmic_data.dmic_num =skl_get_dmic_geo (skl);/* check if dsp is there */ -if (ebus->ppcap) { +if (bus->ppcap) { err =skl_machine_device_register (skl, (void *)pci_id->driver_data);if (err <0 )
@@ -696,7 +696,7 @@ static int skl_probe(struct pci_dev *pci, skl->skl_sst->enable_miscbdcge = skl_enable_miscbdcge; } -if (ebus->mlcap) +if (bus->mlcap)snd_hdac_ext_bus_get_ml_capabilities (ebus);/* create device for soc dmic */
Signature · 1 line
1.9.1
Mark Brown
maintainerApplied "ALSA: convert users to core bus_parse_capabilities" to the asoc tree
The patch
ALSA: convert users to core bus_parse_capabilities
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
ec8ae5703da1b8bd057b4e319567ddbcac295b3aMon Sep 17 00:00:00 2001
From: Vinod Koul <[email protected]>
Date: Thu, 4 Aug 2016 15:46:01 +0530
Subject: [PATCH] ALSA: convert users to core bus_parse_capabilities
Now that we have the bus parse capabilities moved to core, we need to convert users.
The SKL driver and HDA extended lib needs to converted in single patch, otherwise we regress on the functionality.
--- sound/hda/ext/hdac_ext_controller.c | 16 ++++++------ sound/hda/ext/hdac_ext_stream.c | 46 +++++++++++++++++----------------- sound/soc/intel/skylake/skl-messages.c | 4 +-- sound/soc/intel/skylake/skl-pcm.c | 8 +++--- sound/soc/intel/skylake/skl.c | 6 ++--- 5 files changed, 40 insertions(+), 40 deletions(-)
sound/hda/ext/hdac_ext_controller.c +8 -8
@@ -118,15 +118,15 @@ void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus *ebus, bool enable) {struct hdac_bus *bus = &ebus->bus; -if (!ebus->ppcap) { +if (!bus->ppcap) {dev_err (bus->dev,"Address of PP capability is NULL" );return ; }if (enable) -snd_hdac_updatel (ebus->ppcap,AZX_REG_PP_PPCTL ,0 ,AZX_PPCTL_GPROCEN ); +snd_hdac_updatel (bus->ppcap,AZX_REG_PP_PPCTL ,0 ,AZX_PPCTL_GPROCEN );else -snd_hdac_updatel (ebus->ppcap,AZX_REG_PP_PPCTL ,AZX_PPCTL_GPROCEN ,0 ); +snd_hdac_updatel (bus->ppcap,AZX_REG_PP_PPCTL ,AZX_PPCTL_GPROCEN ,0 ); }EXPORT_SYMBOL_GPL (snd_hdac_ext_bus_ppcap_enable);
@@ -139,15 +139,15 @@ void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *ebus, bool enable) {struct hdac_bus *bus = &ebus->bus; -if (!ebus->ppcap) { +if (!bus->ppcap) {dev_err (bus->dev,"Address of PP capability is NULL\n" );return ; }if (enable) -snd_hdac_updatel (ebus->ppcap,AZX_REG_PP_PPCTL ,0 ,AZX_PPCTL_PIE ); +snd_hdac_updatel (bus->ppcap,AZX_REG_PP_PPCTL ,0 ,AZX_PPCTL_PIE );else -snd_hdac_updatel (ebus->ppcap,AZX_REG_PP_PPCTL ,AZX_PPCTL_PIE ,0 ); +snd_hdac_updatel (bus->ppcap,AZX_REG_PP_PPCTL ,AZX_PPCTL_PIE ,0 ); }EXPORT_SYMBOL_GPL (snd_hdac_ext_bus_ppcap_int_enable);
@@ -171,7 +171,7 @@ int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus *ebus)struct hdac_ext_link *hlink;struct hdac_bus *bus = &ebus->bus; - link_count =readl (ebus->mlcap +AZX_REG_ML_MLCD ) +1 ; + link_count =readl (bus->mlcap +AZX_REG_ML_MLCD ) +1 ;dev_dbg (bus->dev,"In %s Link count: %d\n" , __func__, link_count);
@@ -181,7 +181,7 @@ int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus *ebus)return -ENOMEM ; hlink->index = idx; hlink->bus = bus; - hlink->ml_addr = ebus->mlcap +AZX_ML_BASE + + hlink->ml_addr = bus->mlcap +AZX_ML_BASE + (AZX_ML_INTERVAL * idx); hlink->lcaps =readl (hlink->ml_addr +AZX_REG_ML_LCAP ); hlink->lsdiid =readw (hlink->ml_addr +AZX_REG_ML_LSDIID );
sound/hda/ext/hdac_ext_stream.c +23 -23
137 lines not on this page · raw message
sound/soc/intel/skylake/skl-messages.c +2 -2
@@ -296,7 +296,7 @@ int skl_suspend_dsp(struct skl *skl)int ret;/* if ppcap is not supported return 0 */ -if (!skl->ebus.ppcap) +if (!skl->ebus.bus.ppcap)return 0 ; ret =skl_dsp_sleep (ctx->dsp);
@@ -316,7 +316,7 @@ int skl_resume_dsp(struct skl *skl)int ret;/* if ppcap is not supported return 0 */ -if (!skl->ebus.ppcap) +if (!skl->ebus.bus.ppcap)return 0 ;/* enable ppcap interrupt */
sound/soc/intel/skylake/skl-pcm.c +4 -4
@@ -106,7 +106,7 @@ static void skl_set_pcm_constrains(struct hdac_ext_bus *ebus,static enum hdac_ext_stream_type skl_get_host_stream_type (struct hdac_ext_bus *ebus) { -if (ebus->ppcap) +if ((ebus_to_hbus (ebus))->ppcap)return HDAC_EXT_STREAM_TYPE_HOST ;else return HDAC_EXT_STREAM_TYPE_COUPLED ;
@@ -188,7 +188,7 @@ static int skl_get_format(struct snd_pcm_substream *substream,struct hdac_ext_bus *ebus =dev_get_drvdata (dai->dev);int format_val =0 ; -if (ebus->ppcap) { +if ((ebus_to_hbus (ebus))->ppcap) {struct snd_pcm_runtime *runtime = substream->runtime; format_val = snd_hdac_calc_stream_format(runtime->rate,
@@ -1020,7 +1020,7 @@ static int skl_platform_pcm_trigger(struct snd_pcm_substream *substream, {struct hdac_ext_bus *ebus =get_bus_ctx (substream); -if (!ebus->ppcap) +if ((ebus_to_hbus (ebus))->ppcap)return skl_coupled_trigger (substream, cmd);return 0 ;
@@ -1144,7 +1144,7 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform)struct skl *skl =ebus_to_skl (ebus);int ret; -if (ebus->ppcap) { +if ((ebus_to_hbus (ebus))->ppcap) { ret =skl_tplg_init (platform, ebus);if (ret <0 ) {dev_err (platform->dev,"Failed to init topology!\n" );
sound/soc/intel/skylake/skl.c +3 -3
@@ -587,7 +587,7 @@ static int skl_first_init(struct hdac_ext_bus *ebus)return -ENXIO ; } -snd_hdac_ext_bus_parse_capabilities (ebus); +snd_hdac_bus_parse_capabilities (bus);if (skl_acquire_irq (ebus,0 ) <0 )return -EBUSY ;
@@ -682,7 +682,7 @@ static int skl_probe(struct pci_dev *pci, skl_dmic_data.dmic_num =skl_get_dmic_geo (skl);/* check if dsp is there */ -if (ebus->ppcap) { +if (bus->ppcap) { err =skl_machine_device_register (skl, (void *)pci_id->driver_data);if (err <0 )
@@ -696,7 +696,7 @@ static int skl_probe(struct pci_dev *pci, skl->skl_sst->enable_miscbdcge = skl_enable_miscbdcge; } -if (ebus->mlcap) +if (bus->mlcap)snd_hdac_ext_bus_get_ml_capabilities (ebus);/* create device for soc dmic */
Signature · 1 line
2.8.1
PATCH v3 3/5 ALSA - Ext hda: remove bus_parse_capabilities
In reply to Vinod KoulRemove the unused one as we have moved it up to hdac core.
--- include/sound/hdaudio_ext.h | 12 ------ sound/hda/ext/hdac_ext_controller.c | 75 ------------------------------------- 2 files changed, 87 deletions(-)
include/sound/hdaudio_ext.h +0 -12
@@ -8,11 +8,6 @@* * @bus: hdac bus * @num_streams: streams supported -* @ppcap: pp capabilities pointer -* @spbcap: SPIB capabilities pointer -* @mlcap: MultiLink capabilities pointer -* @gtscap: gts capabilities pointer -* @drsmcap: dma resume capabilities pointer * @hlink_list: link list of HDA links * @lock: lock for link mgmt * @cmd_dma_state: state of cmd DMAs: CORB and RIRB
@@ -22,12 +17,6 @@ struct hdac_ext_bus {int num_streams;int idx; -void __iomem *ppcap; -void __iomem *spbcap; -void __iomem *mlcap; -void __iomem *gtscap; -void __iomem *drsmcap; -struct list_head hlink_list;struct mutex lock;
@@ -54,7 +43,6 @@ void snd_hdac_ext_bus_device_remove(struct hdac_ext_bus *ebus);#define HDA_CODEC_EXT_ENTRY (_vid, _revid, _name, _drv_data) \ HDA_CODEC_REV_EXT_ENTRY(_vid, _revid, _name, _drv_data) -int snd_hdac_ext_bus_parse_capabilities (struct hdac_ext_bus *sbus);void snd_hdac_ext_bus_ppcap_enable (struct hdac_ext_bus *chip,bool enable);void snd_hdac_ext_bus_ppcap_int_enable (struct hdac_ext_bus *chip,bool enable);
sound/hda/ext/hdac_ext_controller.c +0 -75
81 lines not on this page · raw message
Signature · 1 line
1.9.1
Mark Brown
maintainerApplied "ALSA - Ext hda: remove bus_parse_capabilities" to the asoc tree
The patch
ALSA - Ext hda: remove bus_parse_capabilities
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
404735c9fd8adff8e5ad11e1f9f8db069d865698Mon Sep 17 00:00:00 2001
From: Vinod Koul <[email protected]>
Date: Thu, 4 Aug 2016 15:46:02 +0530
Subject: [PATCH] ALSA - Ext hda: remove bus_parse_capabilities
Remove the unused one as we have moved it up to hdac core.
--- include/sound/hdaudio_ext.h | 12 ------ sound/hda/ext/hdac_ext_controller.c | 75 ------------------------------------- 2 files changed, 87 deletions(-)
include/sound/hdaudio_ext.h +0 -12
@@ -8,11 +8,6 @@* * @bus: hdac bus * @num_streams: streams supported -* @ppcap: pp capabilities pointer -* @spbcap: SPIB capabilities pointer -* @mlcap: MultiLink capabilities pointer -* @gtscap: gts capabilities pointer -* @drsmcap: dma resume capabilities pointer * @hlink_list: link list of HDA links * @lock: lock for link mgmt * @cmd_dma_state: state of cmd DMAs: CORB and RIRB
@@ -22,12 +17,6 @@ struct hdac_ext_bus {int num_streams;int idx; -void __iomem *ppcap; -void __iomem *spbcap; -void __iomem *mlcap; -void __iomem *gtscap; -void __iomem *drsmcap; -struct list_head hlink_list;struct mutex lock;
@@ -54,7 +43,6 @@ void snd_hdac_ext_bus_device_remove(struct hdac_ext_bus *ebus);#define HDA_CODEC_EXT_ENTRY (_vid, _revid, _name, _drv_data) \ HDA_CODEC_REV_EXT_ENTRY(_vid, _revid, _name, _drv_data) -int snd_hdac_ext_bus_parse_capabilities (struct hdac_ext_bus *sbus);void snd_hdac_ext_bus_ppcap_enable (struct hdac_ext_bus *chip,bool enable);void snd_hdac_ext_bus_ppcap_int_enable (struct hdac_ext_bus *chip,bool enable);
sound/hda/ext/hdac_ext_controller.c +0 -75
81 lines not on this page · raw message
Signature · 1 line
2.8.1
PATCH v3 4/5 ALSA - hda: Add support for parsing new HDA capabilities
In reply to Vinod KoulFrom: Guneshwor Singh <[email protected]>
Skylake onwards HDA controller supports new capabilities like Global Time Stamping (GTS) capability. So add support to parse these new capabilities.
--- include/sound/hda_register.h | 36 ++++++++++++++++++++++++++++++++++++ sound/pci/hda/hda_controller.c | 5 +++++ sound/pci/hda/hda_controller.h | 3 +++ sound/pci/hda/hda_intel.c | 16 ++++++++++++++++ 4 files changed, 60 insertions(+)
include/sound/hda_register.h +36 -0
@@ -89,6 +89,19 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };#define AZX_REG_SD_BDLPL 0x18#define AZX_REG_SD_BDLPU 0x1c +/* GTS registers */ +#define AZX_REG_LLCH 0x14 + +#define AZX_REG_GTS_BASE 0x520 + +#define AZX_REG_GTSCC (AZX_REG_GTS_BASE + 0x00) +#define AZX_REG_WALFCC (AZX_REG_GTS_BASE + 0x04) +#define AZX_REG_TSCCL (AZX_REG_GTS_BASE + 0x08) +#define AZX_REG_TSCCU (AZX_REG_GTS_BASE + 0x0C) +#define AZX_REG_LLPFOC (AZX_REG_GTS_BASE + 0x14) +#define AZX_REG_LLPCL (AZX_REG_GTS_BASE + 0x18) +#define AZX_REG_LLPCU (AZX_REG_GTS_BASE + 0x1C) +/* Haswell/Broadwell display HD-A controller Extended Mode registers */ #define AZX_REG_HSW_EM4 0x100c#define AZX_REG_HSW_EM5 0x1010
@@ -242,6 +255,29 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };/* Interval used to calculate the iterating register offset */ #define AZX_DRSM_INTERVAL 0x08 +/* Global time synchronization registers */ +#define GTSCC_TSCCD_MASK 0x80000000 +#define GTSCC_TSCCD_SHIFT 31 +#define GTSCC_TSCCI_MASK 0x20 +#define GTSCC_CDMAS_DMA_DIR_SHIFT 4 + +#define WALFCC_CIF_MASK 0x1FF +#define WALFCC_FN_SHIFT 9 +#define HDA_CLK_CYCLES_PER_FRAME 512 + +/* +* An error occurs near frame "rollover". The clocks in frame value indicates +* whether this error may have occurred. Here we use the value of 10. Please +* see the errata for the right number [<10] +*/ +#define HDA_MAX_CYCLE_VALUE 499 +#define HDA_MAX_CYCLE_OFFSET 10 +#define HDA_MAX_CYCLE_READ_RETRY 10 + +#define TSCCU_CCU_SHIFT 32 +#define LLPC_CCU_SHIFT 32 + +/* * helpers to read the stream position */
sound/pci/hda/hda_controller.c +5 -0
@@ -412,6 +412,11 @@ static int azx_pcm_open(struct snd_pcm_substream *substream) goto unlock; } runtime->private_data = azx_dev; + +if (chip->gts_present) + azx_pcm_hw.info = azx_pcm_hw.info | +SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME ; + runtime->hw = azx_pcm_hw; runtime->hw.channels_min = hinfo->channels_min; runtime->hw.channels_max = hinfo->channels_max;
sound/pci/hda/hda_controller.h +3 -0
@@ -159,6 +159,9 @@ struct azx { unsigned int region_requested:1; unsigned int disabled:1; /* disabled by vga_switcheroo */ +/* GTS present */ + unsigned int gts_present:1; +#ifdef CONFIG_SND_HDA_DSP_LOADER struct azx_dev saved_azx_dev;#endif
sound/pci/hda/hda_intel.c +16 -0
@@ -1655,6 +1655,22 @@ static int azx_first_init(struct azx *chip)return -ENXIO ; } +if (IS_SKL_PLUS (pci)) +snd_hdac_bus_parse_capabilities (bus); + +/* +* Some Intel CPUs has always running timer (ART) feature and +* controller may have Global time sync reporting capability, so +* check both of these before declaring synchronized time reporting +* capability SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME +*/ + chip->gts_present = false; + +#ifdef CONFIG_X86 +if ((bus->ppcap &&boot_cpu_has (X86_FEATURE_ART ))) + chip->gts_present = true; +#endif +if (chip->msi) {if (chip->driver_caps &AZX_DCAPS_NO_MSI64 ) {dev_dbg (card->dev,"Disabling 64bit MSI\n" );
Signature · 1 line
1.9.1
Re: [PATCH v3 4/5] ALSA - hda: Add support for parsing new HDA capabilities
Quoted 10 lines · Vinod Koul
sound/pci/hda/hda_intel.c +3
-0@@ -1655,6 +1655,22 @@ static int azx_first_init(struct azx *chip)return -ENXIO ; } +if (IS_SKL_PLUS (pci)) +snd_hdac_bus_parse_capabilities (bus); +
sound/pci/hda/hda_intel.c static int azx_first_init(struct azx *chip) · line 1670
Quoted 10 lines
sound/pci/hda/hda_intel.c +10
-0+/* +* Some Intel CPUs has always running timer (ART) feature and +* controller may have Global time sync reporting capability, so +* check both of these before declaring synchronized time reporting +* capability SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME +*/ + chip->gts_present = false; + +#ifdef CONFIG_X86 +if ((bus->ppcap &&boot_cpu_has (X86_FEATURE_ART )))
Superfluous parentheses.
Also, don't we need to include asm/cpufeature.h?
Takashi
Re: [PATCH v3 4/5] ALSA - hda: Add support for parsing new HDA capabilities
Quoted 9 lines · Takashi Iwai
Quoted 7 lines · Vinod Koul
sound/pci/hda/hda_intel.c +0
-0@@ -1655,6 +1655,22 @@ static int azx_first_init(struct azx *chip)return -ENXIO ; }
Quoted 16 lines
sound/pci/hda/hda_intel.c static int azx_first_init(struct azx *chip) · line 1670
Quoted 13 lines
sound/pci/hda/hda_intel.c +13
-0+if (IS_SKL_PLUS (pci)) +snd_hdac_bus_parse_capabilities (bus); + +/* +* Some Intel CPUs has always running timer (ART) feature and +* controller may have Global time sync reporting capability, so +* check both of these before declaring synchronized time reporting +* capability SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME +*/ + chip->gts_present = false; + +#ifdef CONFIG_X86 +if ((bus->ppcap &&boot_cpu_has (X86_FEATURE_ART )))Superfluous parentheses.
Also, don't we need to includeasm/cpufeature.h?
Its somehow included, I will check that part as well
Signature · 1 line
~Vinod
Re: [PATCH v3 4/5] ALSA - hda: Add support for parsing new HDA capabilities
Quoted 8 lines · Vinod Koul
Quoted 6 lines
sound/pci/hda/hda_intel.c static int azx_first_init(struct azx *chip) · line 1670
Quoted 3 lines
sound/pci/hda/hda_intel.c +3
-0+ +#ifdef CONFIG_X86 +if ((bus->ppcap &&boot_cpu_has (X86_FEATURE_ART )))Superfluous parentheses.
Also, don't we need to includeasm/cpufeature.h?Its somehow included, I will check that part as well
And didnt find how :(
Btw we include asm/pgtable.h which uses boot_cpu_has() macro. So somehow it is getting included.
Do you want this be explicitly included?
Signature · 1 line
~Vinod
Re: [PATCH v3 4/5] ALSA - hda: Add support for parsing new HDA capabilities
Quoted 9 lines · Vinod Koul
Quoted 7 lines · Vinod Koul
Quoted 6 lines
sound/pci/hda/hda_intel.c static int azx_first_init(struct azx *chip) · line 1670
Quoted 3 lines
sound/pci/hda/hda_intel.c +3
-0+ +#ifdef CONFIG_X86 +if ((bus->ppcap &&boot_cpu_has (X86_FEATURE_ART )))Superfluous parentheses.
Also, don't we need to includeasm/cpufeature.h?
Quoted 8 lines
Quoted 1 line
Its somehow included, I will check that part as well
And didnt find how :(
Btw we include
asm/pgtable.hwhich usesboot_cpu_has()macro. So somehow it is getting included.Do you want this be explicitly included?
Yes, it's safer.
Takashi
PATCH v3 5/5 ALSA - hda: Add support for link audio time reporting
In reply to Vinod KoulFrom: Guneshwor Singh <[email protected]>
The HDA controller from SKL onwards support additional timestamp reporting of the link time. The link time is read from HW registers and converted to audio values.
--- sound/pci/hda/hda_controller.c | 195 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 194 insertions(+), 1 deletion(-)
sound/pci/hda/hda_controller.c +194 -1
@@ -27,6 +27,12 @@#include <linux/module.h> #include <linux/pm_runtime.h> #include <linux/slab.h> + +#ifdef CONFIG_X86 +/* for art-tsc conversion */ +#include <asm/tsc.h> +#endif +#include <sound/core.h> #include <sound/initval.h> #include "hda_controller.h"
@@ -337,12 +343,169 @@ static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream) azx_get_position(chip, azx_dev)); } +/* +* azx_scale64: Scale base by mult/div while not overflowing sanely +* +* Derived from scale64_check_overflow in kernel/time/timekeeping.c +* +* The tmestamps for a 48Khz stream can overflow after (2^64/10^9)/48K which +* is about 384307 ie ~4.5 days. +* +* This scales the calculation so that overflow will happen but after 2^64 / +* 48000 secs, which is pretty large! +* +* In caln below: +* base may overflow, but since there isn’t any additional division +* performed on base it’s OK +* rem can’t overflow because both are 32-bit values +*/ + +#ifdef CONFIG_X86 +static u64 azx_scale64 (u64 base,u32 num,u32 den) +{ +u64 rem; + + rem =do_div (base, den); + + base *= num; + rem *= num; + +do_div (rem, den); + +return base + rem; +} + +static int azx_get_sync_time (ktime_t *device, +struct system_counterval_t *system,void *ctx) +{ +struct snd_pcm_substream *substream = (struct snd_pcm_substream *)ctx; +struct azx_dev *azx_dev =get_azx_dev (substream); +struct azx_pcm *apcm =snd_pcm_substream_chip (substream); +struct azx *chip = apcm->chip; +struct snd_pcm_runtime *runtime; +u64 ll_counter, ll_counter_l, ll_counter_h; +u64 tsc_counter, tsc_counter_l, tsc_counter_h; +u32 wallclk_ctr, wallclk_cycles; +bool direction; +u32 dma_select; +u32 timeout =200 ; +u32 retry_count =0 ; + + runtime = substream->runtime; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) + direction =1 ; +else + direction =0 ; + +/* 0th stream tag is not used, so DMA ch 0 is for 1st stream tag */ +do { + timeout =100 ; + dma_select = (direction <<GTSCC_CDMAS_DMA_DIR_SHIFT ) | + (azx_dev->core.stream_tag -1 ); +_snd_hdac_chip_write (l,azx_bus (chip),AZX_REG_GTSCC , + dma_select); +/* Enable the capture */ +_snd_hdac_chip_write (l,azx_bus (chip),AZX_REG_GTSCC , +_snd_hdac_chip_read (l,azx_bus (chip), +AZX_REG_GTSCC ) |GTSCC_TSCCI_MASK ); + +while (timeout) { +if (_snd_hdac_chip_read (l,azx_bus (chip), +AZX_REG_GTSCC ) >SCC_TSCCD_MASK ) +break ; + timeout--; + } + +if (!timeout) { +dev_err (chip->card->dev,"GTSCC capture Timedout!\n" ); +return -EIO ; + } + +/* Read wall clock counter */ + wallclk_ctr =_snd_hdac_chip_read (l,azx_bus (chip), +AZX_REG_WALFCC ); + +/* Read TSC counter */ + tsc_counter_l =_snd_hdac_chip_read (l,azx_bus (chip), +AZX_REG_TSCCL ); + tsc_counter_h =_snd_hdac_chip_read (l,azx_bus (chip), +AZX_REG_TSCCU ); + +/* Read Link counter */ + ll_counter_l =_snd_hdac_chip_read (l,azx_bus (chip), +AZX_REG_LLPCL ); + ll_counter_h =_snd_hdac_chip_read (l,azx_bus (chip), +AZX_REG_LLPCU ); + +/* Ack: registers read done */ +_snd_hdac_chip_write (l,azx_bus (chip), +AZX_REG_GTSCC , + (0x1 <<GTSCC_TSCCD_SHIFT )); + + tsc_counter = (tsc_counter_h <<TSCCU_CCU_SHIFT ) | + tsc_counter_l; + + ll_counter = (ll_counter_h <<LLPC_CCU_SHIFT ) | ll_counter_l; + wallclk_cycles = wallclk_ctr &WALFCC_CIF_MASK ; + +/* +* An error occurs near frame "rollover". The clocks in +* frame value indicates whether this error may have +* occurred. Here we use the value of 10 i.e., +* HDA_MAX_CYCLE_OFFSET +*/ +if (wallclk_cycles <HDA_MAX_CYCLE_VALUE -HDA_MAX_CYCLE_OFFSET + && wallclk_cycles >HDA_MAX_CYCLE_OFFSET ) +break ; + +/* +* Sleep before we read again, else we may again get +* value near to MAX_CYCLE. Try to sleep for different +* amount of time so we dont hit the same number again +*/ +udelay (retry_count++); + + }while (retry_count !=HDA_MAX_CYCLE_READ_RETRY ); + +if (retry_count ==HDA_MAX_CYCLE_READ_RETRY ) { +dev_err (chip->card->dev,"Error in WALFCC cycle count\n" ); +return -EIO ; + } + + *device =ns_to_ktime (azx_scale64 (ll_counter, +NSEC_PER_SEC , runtime->rate)); + *device =ktime_add_ns (*device, (wallclk_cycles *NSEC_PER_SEC ) / + ((HDA_MAX_CYCLE_VALUE +1 ) * runtime->rate)); + + *system =convert_art_to_tsc (tsc_counter); + +return 0 ; +} + +#else +static int azx_get_sync_time (ktime_t *device, +struct system_counterval_t *system,void *ctx) +{ +return -ENXIO ; +} +#endif + +static int azx_get_crosststamp (struct snd_pcm_substream *substream, +struct system_device_crosststamp *xtstamp) +{ +return get_device_system_crosststamp (azx_get_sync_time, + substream,NULL , xtstamp); +} +static int azx_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 azx_dev *azx_dev =get_azx_dev (substream); +struct snd_pcm_runtime *runtime = substream->runtime; +struct system_device_crosststamp xtstamp;u64 nsec; if ((substream->runtime->hw.info & SNDRV_PCM_INFO_HAS_LINK_ATIME) &&
@@ -361,8 +524,38 @@ static int azx_get_time_info(struct snd_pcm_substream *substream, audio_tstamp_report->accuracy_report =1 ;/* rest of structure is valid */ audio_tstamp_report->accuracy =42 ;/* 24 MHz WallClock == 42ns resolution */ - }else + }else if ((runtime->hw.info & +SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME ) && + (audio_tstamp_config->type_requested == +SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED )) { + +azx_get_crosststamp (substream, &xtstamp); + +switch (runtime->tstamp_type) { +case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC : +return -EINVAL ; + +case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW : + *system_ts =ktime_to_timespec (xtstamp.sys_monoraw); +break ; + +default : + *system_ts =ktime_to_timespec (xtstamp.sys_realtime); +break ; + + } + + *audio_ts =ktime_to_timespec (xtstamp.device); + + audio_tstamp_report->actual_type = +SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED ; + audio_tstamp_report->accuracy_report =1 ; +/* 24 MHz WallClock == 42ns resolution */ + audio_tstamp_report->accuracy =42 ; + + }else { audio_tstamp_report->actual_type =SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT ; + }return 0 ; }
Signature · 6 lines
1.9.1 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
sound/pci/hda/hda_controller.c static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream) · line 381
Quoted 4 lines · Vinod Koul
sound/pci/hda/hda_controller.c +4
-0+static int azx_get_sync_time (ktime_t *device, +struct system_counterval_t *system,void *ctx) +{ +struct snd_pcm_substream *substream = (struct snd_pcm_substream *)ctx;
Superfluous cast.
Quoted 16 lines
sound/pci/hda/hda_controller.c +16
-0+struct azx_dev *azx_dev =get_azx_dev (substream); +struct azx_pcm *apcm =snd_pcm_substream_chip (substream); +struct azx *chip = apcm->chip; +struct snd_pcm_runtime *runtime; +u64 ll_counter, ll_counter_l, ll_counter_h; +u64 tsc_counter, tsc_counter_l, tsc_counter_h; +u32 wallclk_ctr, wallclk_cycles; +bool direction; +u32 dma_select; +u32 timeout =200 ; +u32 retry_count =0 ; + + runtime = substream->runtime; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) + direction =1 ;
sound/pci/hda/hda_controller.c static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream) · line 407
Quoted 10 lines
sound/pci/hda/hda_controller.c +10
-0+else + direction =0 ; + +/* 0th stream tag is not used, so DMA ch 0 is for 1st stream tag */ + do { + timeout = 100; + dma_select = (direction << GTSCC_CDMAS_DMA_DIR_SHIFT) | + (azx_dev->core.stream_tag - 1); + _snd_hdac_chip_write(l, azx_bus(chip), AZX_REG_GTSCC, + dma_select);
You can use
snd_hdac_chip_writel(azx_bus(chip), GTSCC, dma_select);
The use of _snd_hdac_chip_write() is for non-constant registers. When you pass AZX_REG_XXX, you can use the standard macro. For example:
sound/pci/hda/hda_controller.c static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream) · line 411
Quoted 4 lines
sound/pci/hda/hda_controller.c +4
-0+/* Enable the capture */ +_snd_hdac_chip_write (l,azx_bus (chip),AZX_REG_GTSCC , +_snd_hdac_chip_read (l,azx_bus (chip), +AZX_REG_GTSCC ) |GTSCC_TSCCI_MASK );
This can be simplified with snd_hdac_chip_updatel().
Quoted 51 lines
sound/pci/hda/hda_controller.c +51
-0+ +while (timeout) { +if (_snd_hdac_chip_read (l,azx_bus (chip), +AZX_REG_GTSCC ) >SCC_TSCCD_MASK ) +break ; + timeout--; + } + +if (!timeout) { +dev_err (chip->card->dev,"GTSCC capture Timedout!\n" ); +return -EIO ; + } + +/* Read wall clock counter */ + wallclk_ctr =_snd_hdac_chip_read (l,azx_bus (chip), +AZX_REG_WALFCC ); + +/* Read TSC counter */ + tsc_counter_l =_snd_hdac_chip_read (l,azx_bus (chip), +AZX_REG_TSCCL ); + tsc_counter_h =_snd_hdac_chip_read (l,azx_bus (chip), +AZX_REG_TSCCU ); + +/* Read Link counter */ + ll_counter_l =_snd_hdac_chip_read (l,azx_bus (chip), +AZX_REG_LLPCL ); + ll_counter_h =_snd_hdac_chip_read (l,azx_bus (chip), +AZX_REG_LLPCU ); + +/* Ack: registers read done */ +_snd_hdac_chip_write (l,azx_bus (chip), +AZX_REG_GTSCC , + (0x1 <<GTSCC_TSCCD_SHIFT )); + + tsc_counter = (tsc_counter_h <<TSCCU_CCU_SHIFT ) | + tsc_counter_l; + + ll_counter = (ll_counter_h <<LLPC_CCU_SHIFT ) | ll_counter_l; + wallclk_cycles = wallclk_ctr &WALFCC_CIF_MASK ; + +/* +* An error occurs near frame "rollover". The clocks in +* frame value indicates whether this error may have +* occurred. Here we use the value of 10 i.e., +* HDA_MAX_CYCLE_OFFSET +*/ +if (wallclk_cycles <HDA_MAX_CYCLE_VALUE -HDA_MAX_CYCLE_OFFSET + && wallclk_cycles >HDA_MAX_CYCLE_OFFSET ) +break ; + +/*
sound/pci/hda/hda_controller.c static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream) · line 472
Quoted 10 lines
sound/pci/hda/hda_controller.c +10
-0+* Sleep before we read again, else we may again get +* value near to MAX_CYCLE. Try to sleep for different +* amount of time so we dont hit the same number again +*/ +udelay (retry_count++); + + }while (retry_count !=HDA_MAX_CYCLE_READ_RETRY ); + +if (retry_count ==HDA_MAX_CYCLE_READ_RETRY ) { +dev_err (chip->card->dev,"Error in WALFCC cycle count\n" );
Hrm, this has a danger to spew huge amount of error messages, since this gets called so often.
Quoted 40 lines
sound/pci/hda/hda_controller.c +30
-0+ return -EIO; + } + + *device =ns_to_ktime (azx_scale64 (ll_counter, +NSEC_PER_SEC , runtime->rate)); + *device =ktime_add_ns (*device, (wallclk_cycles *NSEC_PER_SEC ) / + ((HDA_MAX_CYCLE_VALUE +1 ) * runtime->rate)); + + *system =convert_art_to_tsc (tsc_counter); + +return 0 ; +} + +#else +static int azx_get_sync_time (ktime_t *device, +struct system_counterval_t *system,void *ctx) +{ +return -ENXIO ; +} +#endif + +static int azx_get_crosststamp (struct snd_pcm_substream *substream, +struct system_device_crosststamp *xtstamp) +{ +return get_device_system_crosststamp (azx_get_sync_time, + substream,NULL , xtstamp); +} +static int azx_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 azx_dev *azx_dev =get_azx_dev (substream); +struct snd_pcm_runtime *runtime = substream->runtime; +struct system_device_crosststamp xtstamp;u64 nsec; if ((substream->runtime->hw.info & SNDRV_PCM_INFO_HAS_LINK_ATIME) &&
sound/pci/hda/hda_controller.c static int azx_get_time_info(struct snd_pcm_substream *substream, · line 530
Quoted 8 lines
sound/pci/hda/hda_controller.c +4
-1@@ -361,8 +524,38 @@ static int azx_get_time_info(struct snd_pcm_substream *substream, audio_tstamp_report->accuracy_report =1 ;/* rest of structure is valid */ audio_tstamp_report->accuracy =42 ;/* 24 MHz WallClock == 42ns resolution */ - }else + }else if ((runtime->hw.info & +SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME ) && + (audio_tstamp_config->type_requested == +SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED )) {
The indentation is hard to follow here...
sound/pci/hda/hda_controller.c static int azx_get_time_info(struct snd_pcm_substream *substream, · line 532
Quoted 2 lines
sound/pci/hda/hda_controller.c +2
-0+ +azx_get_crosststamp (substream, &xtstamp);
No error check?
thanks,
Takashi
Quoted 32 lines
sound/pci/hda/hda_controller.c +25
-0+ +switch (runtime->tstamp_type) { +case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC : +return -EINVAL ; + +case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW : + *system_ts =ktime_to_timespec (xtstamp.sys_monoraw); +break ; + +default : + *system_ts =ktime_to_timespec (xtstamp.sys_realtime); +break ; + + } + + *audio_ts =ktime_to_timespec (xtstamp.device); + + audio_tstamp_report->actual_type = +SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED ; + audio_tstamp_report->accuracy_report =1 ; +/* 24 MHz WallClock == 42ns resolution */ + audio_tstamp_report->accuracy =42 ; + + }else { audio_tstamp_report->actual_type =SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT ; + }return 0 ; }Signature · 1 line
1.9.1
Quoted 4 lines · Takashi Iwai
Review
Quoted 2 lines
(quoted diff) +2
-0+{ + struct snd_pcm_substream *substream = (struct snd_pcm_substream *)ctx;Superfluous cast.
ok
Quoted 10 lines
sound/pci/hda/hda_controller.c static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream) · line 407
Quoted 4 lines
sound/pci/hda/hda_controller.c +4
-0+ dma_select = (direction <<GTSCC_CDMAS_DMA_DIR_SHIFT ) | + (azx_dev->core.stream_tag -1 ); +_snd_hdac_chip_write (l,azx_bus (chip),AZX_REG_GTSCC , + dma_select);You can use
snd_hdac_chip_writel(azx_bus(chip), GTSCC, dma_select);The use of
_snd_hdac_chip_write()is for non-constant registers. When you passAZX_REG_XXX, you can use the standard macro. For example:
Yes I remeber that. I did see this earlier but missed to update :(
Quoted 6 lines
sound/pci/hda/hda_controller.c static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream) · line 411
Quoted 4 lines
sound/pci/hda/hda_controller.c +4
-0+/* Enable the capture */ +_snd_hdac_chip_write (l,azx_bus (chip),AZX_REG_GTSCC , +_snd_hdac_chip_read (l,azx_bus (chip), +AZX_REG_GTSCC ) |GTSCC_TSCCI_MASK );This can be simplified with
snd_hdac_chip_updatel().
ok
Quoted 5 lines
sound/pci/hda/hda_controller.c static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream) · line 472
Quoted 2 lines
sound/pci/hda/hda_controller.c +2
-0+if (retry_count ==HDA_MAX_CYCLE_READ_RETRY ) { +dev_err (chip->card->dev,"Error in WALFCC cycle count\n" );Hrm, this has a danger to spew huge amount of error messages, since this gets called so often.
print once or rate limit?
Quoted 7 lines
sound/pci/hda/hda_controller.c static int azx_get_time_info(struct snd_pcm_substream *substream, · line 530
Quoted 5 lines
sound/pci/hda/hda_controller.c +4
-1- }else + }else if ((runtime->hw.info & +SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME ) && + (audio_tstamp_config->type_requested == +SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED )) {The indentation is hard to follow here...
will fix
Quoted 5 lines
sound/pci/hda/hda_controller.c static int azx_get_time_info(struct snd_pcm_substream *substream, · line 532
Quoted 3 lines
sound/pci/hda/hda_controller.c +2
-0+ +azx_get_crosststamp (substream, &xtstamp);No error check?
yes will add
Signature · 1 line
~Vinod