^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * @File ctamixer.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * @Brief
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * This file contains the definition of the Audio Mixer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * resource management object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * @Author Liu Chun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * @Date May 21 2008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #ifndef CTAMIXER_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define CTAMIXER_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "ctresource.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) /* Define the descriptor of a summation node resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct sum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct rsc rsc; /* Basic resource info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) unsigned char idx[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /* Define sum resource request description info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct sum_desc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) unsigned int msr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct sum_mgr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct rsc_mgr mgr; /* Basic resource manager info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct snd_card *card; /* pointer to this card */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) spinlock_t mgr_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /* request one sum resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) int (*get_sum)(struct sum_mgr *mgr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) const struct sum_desc *desc, struct sum **rsum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /* return one sum resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) int (*put_sum)(struct sum_mgr *mgr, struct sum *sum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /* Constructor and destructor of daio resource manager */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) int sum_mgr_create(struct hw *hw, struct sum_mgr **rsum_mgr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) int sum_mgr_destroy(struct sum_mgr *sum_mgr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* Define the descriptor of a amixer resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) struct amixer_rsc_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct amixer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct rsc rsc; /* Basic resource info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) unsigned char idx[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct rsc *input; /* pointer to a resource acting as source */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct sum *sum; /* Put amixer output to this summation node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) const struct amixer_rsc_ops *ops; /* AMixer specific operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct amixer_rsc_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int (*set_input)(struct amixer *amixer, struct rsc *rsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) int (*set_scale)(struct amixer *amixer, unsigned int scale);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) int (*set_invalid_squash)(struct amixer *amixer, unsigned int iv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) int (*set_sum)(struct amixer *amixer, struct sum *sum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) int (*commit_write)(struct amixer *amixer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /* Only for interleaved recording */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) int (*commit_raw_write)(struct amixer *amixer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) int (*setup)(struct amixer *amixer, struct rsc *input,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) unsigned int scale, struct sum *sum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) int (*get_scale)(struct amixer *amixer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* Define amixer resource request description info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct amixer_desc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) unsigned int msr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct amixer_mgr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct rsc_mgr mgr; /* Basic resource manager info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct snd_card *card; /* pointer to this card */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) spinlock_t mgr_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /* request one amixer resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) int (*get_amixer)(struct amixer_mgr *mgr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) const struct amixer_desc *desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct amixer **ramixer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /* return one amixer resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) int (*put_amixer)(struct amixer_mgr *mgr, struct amixer *amixer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /* Constructor and destructor of amixer resource manager */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) int amixer_mgr_create(struct hw *hw, struct amixer_mgr **ramixer_mgr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) int amixer_mgr_destroy(struct amixer_mgr *amixer_mgr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #endif /* CTAMIXER_H */