FILE
bcm2835.h
File preview with syntax highlighting.
linux-6.19.14/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* Copyright 2011 Broadcom Corporation. All rights reserved. */ 3 4#ifndef __SOUND_ARM_BCM2835_H 5#define __SOUND_ARM_BCM2835_H 6 7#include <linux/device.h> 8#include <linux/raspberrypi/vchiq.h> 9#include <linux/wait.h> 10#include <sound/core.h> 11#include <sound/pcm.h> 12#include <sound/pcm-indirect.h> 13 14#define MAX_SUBSTREAMS (8) 15#define AVAIL_SUBSTREAMS_MASK (0xff) 16 17enum { 18 CTRL_VOL_MUTE, 19 CTRL_VOL_UNMUTE 20}; 21 22/* macros for alsa2chip and chip2alsa, instead of functions */ 23 24// convert alsa to chip volume (defined as macro rather than function call) 25#define alsa2chip(vol) ((uint)(-(((vol) << 8) / 100))) 26 27// convert chip to alsa volume 28#define chip2alsa(vol) -(((vol) * 100) >> 8) 29 30#define CHIP_MIN_VOLUME 26214 /* minimum level aka mute */ 31 32/* Some constants for values .. */ 33enum snd_bcm2835_route { 34 AUDIO_DEST_AUTO = 0, 35 AUDIO_DEST_HEADPHONES = 1, 36 AUDIO_DEST_HDMI = 2, 37 AUDIO_DEST_MAX, 38}; 39 40enum snd_bcm2835_ctrl { 41 PCM_PLAYBACK_VOLUME, 42 PCM_PLAYBACK_MUTE, 43 PCM_PLAYBACK_DEVICE, 44}; 45 46struct bcm2835_vchi_ctx { 47 struct vchiq_instance *instance; 48}; 49 50/* definition of the chip-specific record */ 51struct bcm2835_chip { 52 struct snd_card *card; 53 struct snd_pcm *pcm; 54 struct snd_pcm *pcm_spdif; 55 struct device *dev; 56 struct bcm2835_alsa_stream *alsa_stream[MAX_SUBSTREAMS]; 57 58 int volume; 59 int dest; 60 int mute; 61 62 unsigned int opened; 63 unsigned int spdif_status; 64 struct mutex audio_mutex; /* Serialize chip data access */ 65 66 struct bcm2835_vchi_ctx *vchi_ctx; 67}; 68 69struct bcm2835_alsa_stream { 70 struct bcm2835_chip *chip; 71 struct snd_pcm_substream *substream; 72 struct snd_pcm_indirect pcm_indirect; 73 74 int draining; 75 76 atomic_t pos; 77 unsigned int period_offset; 78 unsigned int buffer_size; 79 unsigned int period_size; 80 ktime_t interpolate_start; 81 82 struct bcm2835_audio_instance *instance; 83 int idx; 84}; 85 86int snd_bcm2835_new_pcm(struct bcm2835_chip *chip, const char *name, 87 int idx, enum snd_bcm2835_route route, 88 u32 numchannels, bool spdif); 89 90int snd_bcm2835_new_hdmi_ctl(struct bcm2835_chip *chip); 91int snd_bcm2835_new_headphones_ctl(struct bcm2835_chip *chip); 92 93int bcm2835_new_vchi_ctx(struct device *dev, struct bcm2835_vchi_ctx *vchi_ctx); 94void bcm2835_free_vchi_ctx(struct bcm2835_vchi_ctx *vchi_ctx); 95 96int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream); 97int bcm2835_audio_close(struct bcm2835_alsa_stream *alsa_stream); 98int bcm2835_audio_set_params(struct bcm2835_alsa_stream *alsa_stream, 99 unsigned int channels, unsigned int samplerate, 100 unsigned int bps); 101int bcm2835_audio_start(struct bcm2835_alsa_stream *alsa_stream); 102int bcm2835_audio_stop(struct bcm2835_alsa_stream *alsa_stream); 103int bcm2835_audio_drain(struct bcm2835_alsa_stream *alsa_stream); 104int bcm2835_audio_set_ctls(struct bcm2835_alsa_stream *alsa_stream); 105int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream, 106 unsigned int count, 107 void *src); 108void bcm2835_playback_fifo(struct bcm2835_alsa_stream *alsa_stream, 109 unsigned int size); 110unsigned int bcm2835_audio_retrieve_buffers(struct bcm2835_alsa_stream *alsa_stream); 111 112#endif /* __SOUND_ARM_BCM2835_H */
~/
Read-only file preview.