2018-07-02 09:24:45 +03:00
/* SPDX-License-Identifier: GPL-2.0
*
2015-05-29 21:06:14 +03:00
* linux / sound / soc - topology . h - - ALSA SoC Firmware Controls and DAPM
*
* Copyright ( C ) 2012 Texas Instruments Inc .
* Copyright ( C ) 2015 Intel Corporation .
*
* Simple file API to load FW that includes mixers , coefficients , DAPM graphs ,
* algorithms , equalisers , DAIs , widgets , FE caps , BE caps , codec link caps etc .
*/
# ifndef __LINUX_SND_SOC_TPLG_H
# define __LINUX_SND_SOC_TPLG_H
# include <sound/asoc.h>
# include <linux/list.h>
struct firmware ;
struct snd_kcontrol ;
struct snd_soc_tplg_pcm_be ;
struct snd_ctl_elem_value ;
struct snd_ctl_elem_info ;
struct snd_soc_dapm_widget ;
struct snd_soc_component ;
struct snd_soc_tplg_pcm_fe ;
struct snd_soc_dapm_context ;
struct snd_soc_card ;
2017-06-06 17:55:04 +03:00
struct snd_kcontrol_new ;
struct snd_soc_dai_link ;
2018-06-14 22:50:37 +03:00
struct snd_soc_dai_driver ;
struct snd_soc_dai ;
2018-06-14 22:53:59 +03:00
struct snd_soc_dapm_route ;
2015-05-29 21:06:14 +03:00
/* dynamic object type */
enum snd_soc_dobj_type {
SND_SOC_DOBJ_NONE = 0 , /* object is not dynamic */
SND_SOC_DOBJ_MIXER ,
SND_SOC_DOBJ_BYTES ,
2019-01-25 23:06:46 +03:00
SND_SOC_DOBJ_ENUM ,
SND_SOC_DOBJ_GRAPH ,
SND_SOC_DOBJ_WIDGET ,
2015-05-29 21:06:14 +03:00
SND_SOC_DOBJ_DAI_LINK ,
2019-01-25 23:06:46 +03:00
SND_SOC_DOBJ_PCM ,
2015-05-29 21:06:14 +03:00
SND_SOC_DOBJ_CODEC_LINK ,
2019-02-01 20:07:40 +03:00
SND_SOC_DOBJ_BACKEND_LINK ,
2015-05-29 21:06:14 +03:00
} ;
/* dynamic control object */
struct snd_soc_dobj_control {
struct snd_kcontrol * kcontrol ;
char * * dtexts ;
unsigned long * dvalues ;
} ;
/* dynamic widget object */
struct snd_soc_dobj_widget {
2021-05-07 10:02:46 +03:00
unsigned int * kcontrol_type ; /* kcontrol type: mixer, enum, bytes */
2015-05-29 21:06:14 +03:00
} ;
/* generic dynamic object - all dynamic objects belong to this struct */
struct snd_soc_dobj {
enum snd_soc_dobj_type type ;
unsigned int index ; /* objects can belong in different groups */
struct list_head list ;
struct snd_soc_tplg_ops * ops ;
union {
struct snd_soc_dobj_control control ;
struct snd_soc_dobj_widget widget ;
} ;
void * private ; /* core does not touch this */
} ;
/*
* Kcontrol operations - used to map handlers onto firmware based controls .
*/
struct snd_soc_tplg_kcontrol_ops {
u32 id ;
int ( * get ) ( struct snd_kcontrol * kcontrol ,
struct snd_ctl_elem_value * ucontrol ) ;
int ( * put ) ( struct snd_kcontrol * kcontrol ,
struct snd_ctl_elem_value * ucontrol ) ;
int ( * info ) ( struct snd_kcontrol * kcontrol ,
struct snd_ctl_elem_info * uinfo ) ;
} ;
2015-08-18 13:12:20 +03:00
/* Bytes ext operations, for TLV byte controls */
struct snd_soc_tplg_bytes_ext_ops {
u32 id ;
2015-11-09 20:50:00 +03:00
int ( * get ) ( struct snd_kcontrol * kcontrol , unsigned int __user * bytes ,
unsigned int size ) ;
int ( * put ) ( struct snd_kcontrol * kcontrol ,
const unsigned int __user * bytes , unsigned int size ) ;
2015-08-18 13:12:20 +03:00
} ;
2015-05-29 21:06:14 +03:00
/*
* DAPM widget event handlers - used to map handlers onto widgets .
*/
struct snd_soc_tplg_widget_events {
u16 type ;
int ( * event_handler ) ( struct snd_soc_dapm_widget * w ,
struct snd_kcontrol * k , int event ) ;
} ;
/*
* Public API - Used by component drivers to load and unload dynamic objects
* and their resources .
*/
struct snd_soc_tplg_ops {
/* external kcontrol init - used for any driver specific init */
2018-06-14 22:50:37 +03:00
int ( * control_load ) ( struct snd_soc_component * , int index ,
2015-05-29 21:06:14 +03:00
struct snd_kcontrol_new * , struct snd_soc_tplg_ctl_hdr * ) ;
int ( * control_unload ) ( struct snd_soc_component * ,
struct snd_soc_dobj * ) ;
2018-06-14 22:53:59 +03:00
/* DAPM graph route element loading and unloading */
int ( * dapm_route_load ) ( struct snd_soc_component * , int index ,
struct snd_soc_dapm_route * route ) ;
int ( * dapm_route_unload ) ( struct snd_soc_component * ,
struct snd_soc_dobj * ) ;
2015-05-29 21:06:14 +03:00
/* external widget init - used for any driver specific init */
2018-06-14 22:50:37 +03:00
int ( * widget_load ) ( struct snd_soc_component * , int index ,
2015-05-29 21:06:14 +03:00
struct snd_soc_dapm_widget * ,
struct snd_soc_tplg_dapm_widget * ) ;
2018-06-14 22:50:37 +03:00
int ( * widget_ready ) ( struct snd_soc_component * , int index ,
2017-06-09 17:43:23 +03:00
struct snd_soc_dapm_widget * ,
struct snd_soc_tplg_dapm_widget * ) ;
2015-05-29 21:06:14 +03:00
int ( * widget_unload ) ( struct snd_soc_component * ,
struct snd_soc_dobj * ) ;
2016-01-15 11:13:28 +03:00
/* FE DAI - used for any driver specific init */
2018-06-14 22:50:37 +03:00
int ( * dai_load ) ( struct snd_soc_component * , int index ,
struct snd_soc_dai_driver * dai_drv ,
struct snd_soc_tplg_pcm * pcm , struct snd_soc_dai * dai ) ;
2016-01-15 11:13:28 +03:00
int ( * dai_unload ) ( struct snd_soc_component * ,
2015-05-29 21:06:14 +03:00
struct snd_soc_dobj * ) ;
2016-01-15 11:13:37 +03:00
/* DAI link - used for any driver specific init */
2018-06-14 22:50:37 +03:00
int ( * link_load ) ( struct snd_soc_component * , int index ,
struct snd_soc_dai_link * link ,
struct snd_soc_tplg_link_config * cfg ) ;
2016-01-15 11:13:37 +03:00
int ( * link_unload ) ( struct snd_soc_component * ,
struct snd_soc_dobj * ) ;
2015-05-29 21:06:14 +03:00
/* callback to handle vendor bespoke data */
2018-06-14 22:50:37 +03:00
int ( * vendor_load ) ( struct snd_soc_component * , int index ,
2015-05-29 21:06:14 +03:00
struct snd_soc_tplg_hdr * ) ;
int ( * vendor_unload ) ( struct snd_soc_component * ,
struct snd_soc_tplg_hdr * ) ;
/* completion - called at completion of firmware loading */
2021-09-27 15:05:06 +03:00
int ( * complete ) ( struct snd_soc_component * comp ) ;
2015-05-29 21:06:14 +03:00
/* manifest - optional to inform component of manifest */
2018-06-14 22:50:37 +03:00
int ( * manifest ) ( struct snd_soc_component * , int index ,
2015-05-29 21:06:14 +03:00
struct snd_soc_tplg_manifest * ) ;
2015-08-18 13:11:51 +03:00
/* vendor specific kcontrol handlers available for binding */
2015-05-29 21:06:14 +03:00
const struct snd_soc_tplg_kcontrol_ops * io_ops ;
int io_ops_count ;
2015-08-18 13:12:20 +03:00
/* vendor specific bytes ext handlers available for binding */
const struct snd_soc_tplg_bytes_ext_ops * bytes_ext_ops ;
int bytes_ext_ops_count ;
2015-05-29 21:06:14 +03:00
} ;
2015-08-15 18:24:20 +03:00
# ifdef CONFIG_SND_SOC_TOPOLOGY
2015-05-29 21:06:14 +03:00
/* gets a pointer to data from the firmware block header */
static inline const void * snd_soc_tplg_get_data ( struct snd_soc_tplg_hdr * hdr )
{
const void * ptr = hdr ;
return ptr + sizeof ( * hdr ) ;
}
/* Dynamic Object loading and removal for component drivers */
int snd_soc_tplg_component_load ( struct snd_soc_component * comp ,
2020-10-30 17:54:23 +03:00
struct snd_soc_tplg_ops * ops , const struct firmware * fw ) ;
int snd_soc_tplg_component_remove ( struct snd_soc_component * comp ) ;
2015-05-29 21:06:14 +03:00
/* Binds event handlers to dynamic widgets */
int snd_soc_tplg_widget_bind_event ( struct snd_soc_dapm_widget * w ,
const struct snd_soc_tplg_widget_events * events , int num_events ,
u16 event_type ) ;
2015-08-15 18:24:20 +03:00
# else
2021-10-25 18:48:44 +03:00
static inline int snd_soc_tplg_component_remove ( struct snd_soc_component * comp )
2015-08-15 18:24:20 +03:00
{
return 0 ;
}
# endif
2015-05-29 21:06:14 +03:00
# endif