ALSA: usb-audio: Constify audioformat pointer references
The audioformat is referred in many places but most of usages are read-only. Let's add const prefix in the possible places. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-28-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
c15871e17f
commit
cab941b7e5
|
@ -120,7 +120,7 @@ struct snd_usb_endpoint {
|
|||
bool need_setup; /* (re-)need for configure? */
|
||||
|
||||
/* for hw constraints */
|
||||
struct audioformat *cur_audiofmt;
|
||||
const struct audioformat *cur_audiofmt;
|
||||
unsigned int cur_rate;
|
||||
snd_pcm_format_t cur_format;
|
||||
unsigned int cur_channels;
|
||||
|
@ -142,7 +142,7 @@ struct snd_usb_substream {
|
|||
int direction; /* playback or capture */
|
||||
int interface; /* current interface */
|
||||
int endpoint; /* assigned endpoint */
|
||||
struct audioformat *cur_audiofmt; /* current audioformat pointer (for hw_params callback) */
|
||||
const struct audioformat *cur_audiofmt; /* current audioformat pointer (for hw_params callback) */
|
||||
struct snd_usb_power_domain *str_pd; /* UAC3 Power Domain for streaming path */
|
||||
snd_pcm_format_t pcm_format; /* current audio format (for hw_params callback) */
|
||||
unsigned int channels; /* current number of channels (for hw_params callback) */
|
||||
|
|
|
@ -152,7 +152,7 @@ static int uac_clock_selector_set_val(struct snd_usb_audio *chip, int selector_i
|
|||
}
|
||||
|
||||
static bool uac_clock_source_is_valid_quirk(struct snd_usb_audio *chip,
|
||||
struct audioformat *fmt,
|
||||
const struct audioformat *fmt,
|
||||
int source_id)
|
||||
{
|
||||
bool ret = false;
|
||||
|
@ -215,7 +215,7 @@ static bool uac_clock_source_is_valid_quirk(struct snd_usb_audio *chip,
|
|||
}
|
||||
|
||||
static bool uac_clock_source_is_valid(struct snd_usb_audio *chip,
|
||||
struct audioformat *fmt,
|
||||
const struct audioformat *fmt,
|
||||
int source_id)
|
||||
{
|
||||
int err;
|
||||
|
@ -264,7 +264,7 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip,
|
|||
}
|
||||
|
||||
static int __uac_clock_find_source(struct snd_usb_audio *chip,
|
||||
struct audioformat *fmt, int entity_id,
|
||||
const struct audioformat *fmt, int entity_id,
|
||||
unsigned long *visited, bool validate)
|
||||
{
|
||||
struct uac_clock_source_descriptor *source;
|
||||
|
@ -358,7 +358,7 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
|
|||
}
|
||||
|
||||
static int __uac3_clock_find_source(struct snd_usb_audio *chip,
|
||||
struct audioformat *fmt, int entity_id,
|
||||
const struct audioformat *fmt, int entity_id,
|
||||
unsigned long *visited, bool validate)
|
||||
{
|
||||
struct uac3_clock_source_descriptor *source;
|
||||
|
@ -464,7 +464,7 @@ static int __uac3_clock_find_source(struct snd_usb_audio *chip,
|
|||
* Returns the clock source UnitID (>=0) on success, or an error.
|
||||
*/
|
||||
int snd_usb_clock_find_source(struct snd_usb_audio *chip,
|
||||
struct audioformat *fmt, bool validate)
|
||||
const struct audioformat *fmt, bool validate)
|
||||
{
|
||||
DECLARE_BITMAP(visited, 256);
|
||||
memset(visited, 0, sizeof(visited));
|
||||
|
@ -482,7 +482,7 @@ int snd_usb_clock_find_source(struct snd_usb_audio *chip,
|
|||
}
|
||||
|
||||
static int set_sample_rate_v1(struct snd_usb_audio *chip,
|
||||
struct audioformat *fmt, int rate)
|
||||
const struct audioformat *fmt, int rate)
|
||||
{
|
||||
struct usb_device *dev = chip->dev;
|
||||
struct usb_host_interface *alts;
|
||||
|
@ -611,7 +611,7 @@ int snd_usb_set_sample_rate_v2v3(struct snd_usb_audio *chip,
|
|||
}
|
||||
|
||||
static int set_sample_rate_v2v3(struct snd_usb_audio *chip,
|
||||
struct audioformat *fmt, int rate)
|
||||
const struct audioformat *fmt, int rate)
|
||||
{
|
||||
int cur_rate, prev_rate;
|
||||
int clock;
|
||||
|
@ -663,7 +663,7 @@ validation:
|
|||
}
|
||||
|
||||
int snd_usb_init_sample_rate(struct snd_usb_audio *chip,
|
||||
struct audioformat *fmt, int rate)
|
||||
const struct audioformat *fmt, int rate)
|
||||
{
|
||||
usb_audio_dbg(chip, "%d:%d Set sample rate %d, clock %d\n",
|
||||
fmt->iface, fmt->altsetting, rate, fmt->clock);
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
#define __USBAUDIO_CLOCK_H
|
||||
|
||||
int snd_usb_init_sample_rate(struct snd_usb_audio *chip,
|
||||
struct audioformat *fmt, int rate);
|
||||
const struct audioformat *fmt, int rate);
|
||||
|
||||
int snd_usb_clock_find_source(struct snd_usb_audio *chip,
|
||||
struct audioformat *fmt, bool validate);
|
||||
const struct audioformat *fmt, bool validate);
|
||||
|
||||
int snd_usb_set_sample_rate_v2v3(struct snd_usb_audio *chip,
|
||||
const struct audioformat *fmt,
|
||||
|
|
|
@ -623,7 +623,7 @@ bool snd_usb_endpoint_compatible(struct snd_usb_audio *chip,
|
|||
*/
|
||||
struct snd_usb_endpoint *
|
||||
snd_usb_endpoint_open(struct snd_usb_audio *chip,
|
||||
struct audioformat *fp,
|
||||
const struct audioformat *fp,
|
||||
const struct snd_pcm_hw_params *params,
|
||||
bool is_sync_ep)
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ int snd_usb_add_endpoint(struct snd_usb_audio *chip, int ep_num, int type);
|
|||
|
||||
struct snd_usb_endpoint *
|
||||
snd_usb_endpoint_open(struct snd_usb_audio *chip,
|
||||
struct audioformat *fp,
|
||||
const struct audioformat *fp,
|
||||
const struct snd_pcm_hw_params *params,
|
||||
bool is_sync_ep);
|
||||
void snd_usb_endpoint_close(struct snd_usb_audio *chip,
|
||||
|
|
|
@ -80,13 +80,13 @@ static snd_pcm_uframes_t snd_usb_pcm_pointer(struct snd_pcm_substream *substream
|
|||
/*
|
||||
* find a matching audio format
|
||||
*/
|
||||
static struct audioformat *
|
||||
static const struct audioformat *
|
||||
find_format(struct list_head *fmt_list_head, snd_pcm_format_t format,
|
||||
unsigned int rate, unsigned int channels, bool strict_match,
|
||||
struct snd_usb_substream *subs)
|
||||
{
|
||||
struct audioformat *fp;
|
||||
struct audioformat *found = NULL;
|
||||
const struct audioformat *fp;
|
||||
const struct audioformat *found = NULL;
|
||||
int cur_attr = 0, attr;
|
||||
|
||||
list_for_each_entry(fp, fmt_list_head, list) {
|
||||
|
@ -141,7 +141,7 @@ find_format(struct list_head *fmt_list_head, snd_pcm_format_t format,
|
|||
return found;
|
||||
}
|
||||
|
||||
static struct audioformat *
|
||||
static const struct audioformat *
|
||||
find_substream_format(struct snd_usb_substream *subs,
|
||||
const struct snd_pcm_hw_params *params)
|
||||
{
|
||||
|
@ -182,7 +182,7 @@ static int init_pitch_v2(struct snd_usb_audio *chip, int ep)
|
|||
* initialize the pitch control and sample rate
|
||||
*/
|
||||
int snd_usb_init_pitch(struct snd_usb_audio *chip,
|
||||
struct audioformat *fmt)
|
||||
const struct audioformat *fmt)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
@ -641,14 +641,14 @@ find_matching_substream(struct snd_usb_audio *chip, int stream, int ep_num,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct audioformat *
|
||||
static const struct audioformat *
|
||||
find_implicit_fb_sync_format(struct snd_usb_audio *chip,
|
||||
const struct audioformat *target,
|
||||
const struct snd_pcm_hw_params *params,
|
||||
int stream)
|
||||
{
|
||||
struct snd_usb_substream *subs;
|
||||
struct audioformat *fp, *sync_fmt;
|
||||
const struct audioformat *fp, *sync_fmt;
|
||||
int score, high_score;
|
||||
|
||||
subs = find_matching_substream(chip, stream, target->sync_ep,
|
||||
|
@ -726,8 +726,8 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
|
|||
{
|
||||
struct snd_usb_substream *subs = substream->runtime->private_data;
|
||||
struct snd_usb_audio *chip = subs->stream->chip;
|
||||
struct audioformat *fmt;
|
||||
struct audioformat *sync_fmt;
|
||||
const struct audioformat *fmt;
|
||||
const struct audioformat *sync_fmt;
|
||||
int ret;
|
||||
|
||||
ret = snd_media_start_pipeline(subs);
|
||||
|
@ -918,7 +918,7 @@ static const struct snd_pcm_hardware snd_usb_hardware =
|
|||
|
||||
static int hw_check_valid_format(struct snd_usb_substream *subs,
|
||||
struct snd_pcm_hw_params *params,
|
||||
struct audioformat *fp)
|
||||
const struct audioformat *fp)
|
||||
{
|
||||
struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
|
||||
struct snd_interval *ct = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
|
||||
|
@ -995,7 +995,7 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params,
|
|||
struct snd_pcm_hw_rule *rule)
|
||||
{
|
||||
struct snd_usb_substream *subs = rule->private;
|
||||
struct audioformat *fp;
|
||||
const struct audioformat *fp;
|
||||
struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
|
||||
unsigned int rmin, rmax, r;
|
||||
int i;
|
||||
|
@ -1028,7 +1028,7 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params,
|
|||
struct snd_pcm_hw_rule *rule)
|
||||
{
|
||||
struct snd_usb_substream *subs = rule->private;
|
||||
struct audioformat *fp;
|
||||
const struct audioformat *fp;
|
||||
struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
|
||||
unsigned int rmin, rmax;
|
||||
|
||||
|
@ -1049,7 +1049,7 @@ static int hw_rule_format(struct snd_pcm_hw_params *params,
|
|||
struct snd_pcm_hw_rule *rule)
|
||||
{
|
||||
struct snd_usb_substream *subs = rule->private;
|
||||
struct audioformat *fp;
|
||||
const struct audioformat *fp;
|
||||
struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
|
||||
u64 fbits;
|
||||
u32 oldbits[2];
|
||||
|
@ -1080,7 +1080,7 @@ static int hw_rule_period_time(struct snd_pcm_hw_params *params,
|
|||
struct snd_pcm_hw_rule *rule)
|
||||
{
|
||||
struct snd_usb_substream *subs = rule->private;
|
||||
struct audioformat *fp;
|
||||
const struct audioformat *fp;
|
||||
struct snd_interval *it;
|
||||
unsigned char min_datainterval;
|
||||
unsigned int pmin;
|
||||
|
@ -1109,7 +1109,7 @@ static int apply_hw_constraint_from_sync(struct snd_pcm_runtime *runtime,
|
|||
{
|
||||
struct snd_usb_audio *chip = subs->stream->chip;
|
||||
struct snd_usb_endpoint *ep;
|
||||
struct audioformat *fp;
|
||||
const struct audioformat *fp;
|
||||
int err;
|
||||
|
||||
list_for_each_entry(fp, &subs->fmt_list, list) {
|
||||
|
@ -1170,7 +1170,7 @@ static int apply_hw_constraint_from_sync(struct snd_pcm_runtime *runtime,
|
|||
static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs)
|
||||
{
|
||||
struct snd_usb_audio *chip = subs->stream->chip;
|
||||
struct audioformat *fp;
|
||||
const struct audioformat *fp;
|
||||
unsigned int pt, ptmin;
|
||||
int param_period_time_if_needed = -1;
|
||||
int err;
|
||||
|
|
|
@ -10,7 +10,7 @@ int snd_usb_pcm_suspend(struct snd_usb_stream *as);
|
|||
int snd_usb_pcm_resume(struct snd_usb_stream *as);
|
||||
|
||||
int snd_usb_init_pitch(struct snd_usb_audio *chip,
|
||||
struct audioformat *fmt);
|
||||
const struct audioformat *fmt);
|
||||
void snd_usb_preallocate_buffer(struct snd_usb_substream *subs);
|
||||
|
||||
int snd_usb_audioformat_set_sync_ep(struct snd_usb_audio *chip,
|
||||
|
|
|
@ -1375,7 +1375,8 @@ int snd_usb_apply_boot_quirk_once(struct usb_device *dev,
|
|||
/*
|
||||
* check if the device uses big-endian samples
|
||||
*/
|
||||
int snd_usb_is_big_endian_format(struct snd_usb_audio *chip, struct audioformat *fp)
|
||||
int snd_usb_is_big_endian_format(struct snd_usb_audio *chip,
|
||||
const struct audioformat *fp)
|
||||
{
|
||||
/* it depends on altsetting whether the device is big-endian or not */
|
||||
switch (chip->usb_id) {
|
||||
|
@ -1414,7 +1415,7 @@ enum {
|
|||
};
|
||||
|
||||
static void set_format_emu_quirk(struct snd_usb_substream *subs,
|
||||
struct audioformat *fmt)
|
||||
const struct audioformat *fmt)
|
||||
{
|
||||
unsigned char emu_samplerate_id = 0;
|
||||
|
||||
|
@ -1476,7 +1477,7 @@ static int pioneer_djm_set_format_quirk(struct snd_usb_substream *subs)
|
|||
}
|
||||
|
||||
void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
|
||||
struct audioformat *fmt)
|
||||
const struct audioformat *fmt)
|
||||
{
|
||||
switch (subs->stream->chip->usb_id) {
|
||||
case USB_ID(0x041e, 0x3f02): /* E-Mu 0202 USB */
|
||||
|
@ -1543,7 +1544,7 @@ static bool is_itf_usb_dsd_dac(unsigned int id)
|
|||
}
|
||||
|
||||
int snd_usb_select_mode_quirk(struct snd_usb_audio *chip,
|
||||
struct audioformat *fmt)
|
||||
const struct audioformat *fmt)
|
||||
{
|
||||
struct usb_device *dev = chip->dev;
|
||||
int err;
|
||||
|
|
|
@ -26,12 +26,12 @@ int snd_usb_apply_boot_quirk_once(struct usb_device *dev,
|
|||
unsigned int usb_id);
|
||||
|
||||
void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
|
||||
struct audioformat *fmt);
|
||||
const struct audioformat *fmt);
|
||||
|
||||
bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip);
|
||||
|
||||
int snd_usb_is_big_endian_format(struct snd_usb_audio *chip,
|
||||
struct audioformat *fp);
|
||||
const struct audioformat *fp);
|
||||
|
||||
void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep);
|
||||
|
||||
|
@ -41,7 +41,7 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
|
|||
__u16 index, void *data, __u16 size);
|
||||
|
||||
int snd_usb_select_mode_quirk(struct snd_usb_audio *chip,
|
||||
struct audioformat *fmt);
|
||||
const struct audioformat *fmt);
|
||||
|
||||
u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
|
||||
struct audioformat *fp,
|
||||
|
|
Loading…
Reference in New Issue