18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/** 38c2ecf20Sopenharmony_ci * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * @File ctamixer.h 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * @Brief 88c2ecf20Sopenharmony_ci * This file contains the definition of the Audio Mixer 98c2ecf20Sopenharmony_ci * resource management object. 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * @Author Liu Chun 128c2ecf20Sopenharmony_ci * @Date May 21 2008 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#ifndef CTAMIXER_H 168c2ecf20Sopenharmony_ci#define CTAMIXER_H 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include "ctresource.h" 198c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 208c2ecf20Sopenharmony_ci#include <sound/core.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci/* Define the descriptor of a summation node resource */ 238c2ecf20Sopenharmony_cistruct sum { 248c2ecf20Sopenharmony_ci struct rsc rsc; /* Basic resource info */ 258c2ecf20Sopenharmony_ci unsigned char idx[8]; 268c2ecf20Sopenharmony_ci}; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* Define sum resource request description info */ 298c2ecf20Sopenharmony_cistruct sum_desc { 308c2ecf20Sopenharmony_ci unsigned int msr; 318c2ecf20Sopenharmony_ci}; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistruct sum_mgr { 348c2ecf20Sopenharmony_ci struct rsc_mgr mgr; /* Basic resource manager info */ 358c2ecf20Sopenharmony_ci struct snd_card *card; /* pointer to this card */ 368c2ecf20Sopenharmony_ci spinlock_t mgr_lock; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci /* request one sum resource */ 398c2ecf20Sopenharmony_ci int (*get_sum)(struct sum_mgr *mgr, 408c2ecf20Sopenharmony_ci const struct sum_desc *desc, struct sum **rsum); 418c2ecf20Sopenharmony_ci /* return one sum resource */ 428c2ecf20Sopenharmony_ci int (*put_sum)(struct sum_mgr *mgr, struct sum *sum); 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* Constructor and destructor of daio resource manager */ 468c2ecf20Sopenharmony_ciint sum_mgr_create(struct hw *hw, struct sum_mgr **rsum_mgr); 478c2ecf20Sopenharmony_ciint sum_mgr_destroy(struct sum_mgr *sum_mgr); 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci/* Define the descriptor of a amixer resource */ 508c2ecf20Sopenharmony_cistruct amixer_rsc_ops; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistruct amixer { 538c2ecf20Sopenharmony_ci struct rsc rsc; /* Basic resource info */ 548c2ecf20Sopenharmony_ci unsigned char idx[8]; 558c2ecf20Sopenharmony_ci struct rsc *input; /* pointer to a resource acting as source */ 568c2ecf20Sopenharmony_ci struct sum *sum; /* Put amixer output to this summation node */ 578c2ecf20Sopenharmony_ci const struct amixer_rsc_ops *ops; /* AMixer specific operations */ 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistruct amixer_rsc_ops { 618c2ecf20Sopenharmony_ci int (*set_input)(struct amixer *amixer, struct rsc *rsc); 628c2ecf20Sopenharmony_ci int (*set_scale)(struct amixer *amixer, unsigned int scale); 638c2ecf20Sopenharmony_ci int (*set_invalid_squash)(struct amixer *amixer, unsigned int iv); 648c2ecf20Sopenharmony_ci int (*set_sum)(struct amixer *amixer, struct sum *sum); 658c2ecf20Sopenharmony_ci int (*commit_write)(struct amixer *amixer); 668c2ecf20Sopenharmony_ci /* Only for interleaved recording */ 678c2ecf20Sopenharmony_ci int (*commit_raw_write)(struct amixer *amixer); 688c2ecf20Sopenharmony_ci int (*setup)(struct amixer *amixer, struct rsc *input, 698c2ecf20Sopenharmony_ci unsigned int scale, struct sum *sum); 708c2ecf20Sopenharmony_ci int (*get_scale)(struct amixer *amixer); 718c2ecf20Sopenharmony_ci}; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci/* Define amixer resource request description info */ 748c2ecf20Sopenharmony_cistruct amixer_desc { 758c2ecf20Sopenharmony_ci unsigned int msr; 768c2ecf20Sopenharmony_ci}; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cistruct amixer_mgr { 798c2ecf20Sopenharmony_ci struct rsc_mgr mgr; /* Basic resource manager info */ 808c2ecf20Sopenharmony_ci struct snd_card *card; /* pointer to this card */ 818c2ecf20Sopenharmony_ci spinlock_t mgr_lock; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci /* request one amixer resource */ 848c2ecf20Sopenharmony_ci int (*get_amixer)(struct amixer_mgr *mgr, 858c2ecf20Sopenharmony_ci const struct amixer_desc *desc, 868c2ecf20Sopenharmony_ci struct amixer **ramixer); 878c2ecf20Sopenharmony_ci /* return one amixer resource */ 888c2ecf20Sopenharmony_ci int (*put_amixer)(struct amixer_mgr *mgr, struct amixer *amixer); 898c2ecf20Sopenharmony_ci}; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* Constructor and destructor of amixer resource manager */ 928c2ecf20Sopenharmony_ciint amixer_mgr_create(struct hw *hw, struct amixer_mgr **ramixer_mgr); 938c2ecf20Sopenharmony_ciint amixer_mgr_destroy(struct amixer_mgr *amixer_mgr); 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci#endif /* CTAMIXER_H */ 96