brintos

brintos / linux-shallow public Read only

0
0
Text · 1.6 KiB · 6dcdb32 Raw
50 lines · c
1/* SPDX-License-Identifier: GPL-2.02 *3 * linux/sound/sdw.h -- SoundWire helpers for ALSA/ASoC4 *5 * Copyright (c) 2022 Cirrus Logic Inc.6 *7 * Author: Charles Keepax <ckeepax@opensource.cirrus.com>8 */9 10#include <linux/soundwire/sdw.h>11#include <sound/asound.h>12#include <sound/pcm.h>13#include <sound/pcm_params.h>14 15#ifndef __INCLUDE_SOUND_SDW_H16#define __INCLUDE_SOUND_SDW_H17 18/**19 * snd_sdw_params_to_config() - Conversion from hw_params to SoundWire config20 *21 * @substream: Pointer to the PCM substream structure22 * @params: Pointer to the hardware params structure23 * @stream_config: Stream configuration for the SoundWire audio stream24 * @port_config: Port configuration for the SoundWire audio stream25 *26 * This function provides a basic conversion from the hw_params structure to27 * SoundWire configuration structures. The user will at a minimum need to also28 * set the port number in the port config, but may also override more of the29 * setup, or in the case of a complex user, not use this helper at all and30 * open-code everything.31 */32static inline void snd_sdw_params_to_config(struct snd_pcm_substream *substream,33					    struct snd_pcm_hw_params *params,34					    struct sdw_stream_config *stream_config,35					    struct sdw_port_config *port_config)36{37	stream_config->frame_rate = params_rate(params);38	stream_config->ch_count = params_channels(params);39	stream_config->bps = snd_pcm_format_width(params_format(params));40 41	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)42		stream_config->direction = SDW_DATA_DIR_RX;43	else44		stream_config->direction = SDW_DATA_DIR_TX;45 46	port_config->ch_mask = GENMASK(stream_config->ch_count - 1, 0);47}48 49#endif50