xref: /kernel/linux/linux-5.10/sound/pci/ctxfi/ctdaio.h (revision 8c2ecf20)
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	ctdaio.h
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * @Brief
88c2ecf20Sopenharmony_ci * This file contains the definition of Digital Audio Input Output
98c2ecf20Sopenharmony_ci * resource management object.
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * @Author	Liu Chun
128c2ecf20Sopenharmony_ci * @Date 	May 23 2008
138c2ecf20Sopenharmony_ci */
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#ifndef CTDAIO_H
168c2ecf20Sopenharmony_ci#define CTDAIO_H
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#include "ctresource.h"
198c2ecf20Sopenharmony_ci#include "ctimap.h"
208c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
218c2ecf20Sopenharmony_ci#include <linux/list.h>
228c2ecf20Sopenharmony_ci#include <sound/core.h>
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/* Define the descriptor of a daio resource */
258c2ecf20Sopenharmony_cienum DAIOTYP {
268c2ecf20Sopenharmony_ci	LINEO1,
278c2ecf20Sopenharmony_ci	LINEO2,
288c2ecf20Sopenharmony_ci	LINEO3,
298c2ecf20Sopenharmony_ci	LINEO4,
308c2ecf20Sopenharmony_ci	SPDIFOO,	/* S/PDIF Out (Flexijack/Optical) */
318c2ecf20Sopenharmony_ci	LINEIM,
328c2ecf20Sopenharmony_ci	SPDIFIO,	/* S/PDIF In (Flexijack/Optical) on the card */
338c2ecf20Sopenharmony_ci	MIC,		/* Dedicated mic on Titanium HD */
348c2ecf20Sopenharmony_ci	SPDIFI1,	/* S/PDIF In on internal Drive Bay */
358c2ecf20Sopenharmony_ci	NUM_DAIOTYP
368c2ecf20Sopenharmony_ci};
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_cistruct dao_rsc_ops;
398c2ecf20Sopenharmony_cistruct dai_rsc_ops;
408c2ecf20Sopenharmony_cistruct daio_mgr;
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_cistruct daio {
438c2ecf20Sopenharmony_ci	struct rsc rscl;	/* Basic resource info for left TX/RX */
448c2ecf20Sopenharmony_ci	struct rsc rscr;	/* Basic resource info for right TX/RX */
458c2ecf20Sopenharmony_ci	enum DAIOTYP type;
468c2ecf20Sopenharmony_ci};
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_cistruct dao {
498c2ecf20Sopenharmony_ci	struct daio daio;
508c2ecf20Sopenharmony_ci	const struct dao_rsc_ops *ops;	/* DAO specific operations */
518c2ecf20Sopenharmony_ci	struct imapper **imappers;
528c2ecf20Sopenharmony_ci	struct daio_mgr *mgr;
538c2ecf20Sopenharmony_ci	struct hw *hw;
548c2ecf20Sopenharmony_ci	void *ctrl_blk;
558c2ecf20Sopenharmony_ci};
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_cistruct dai {
588c2ecf20Sopenharmony_ci	struct daio daio;
598c2ecf20Sopenharmony_ci	const struct dai_rsc_ops *ops;	/* DAI specific operations */
608c2ecf20Sopenharmony_ci	struct hw *hw;
618c2ecf20Sopenharmony_ci	void *ctrl_blk;
628c2ecf20Sopenharmony_ci};
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cistruct dao_desc {
658c2ecf20Sopenharmony_ci	unsigned int msr:4;
668c2ecf20Sopenharmony_ci	unsigned int passthru:1;
678c2ecf20Sopenharmony_ci};
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistruct dao_rsc_ops {
708c2ecf20Sopenharmony_ci	int (*set_spos)(struct dao *dao, unsigned int spos);
718c2ecf20Sopenharmony_ci	int (*commit_write)(struct dao *dao);
728c2ecf20Sopenharmony_ci	int (*get_spos)(struct dao *dao, unsigned int *spos);
738c2ecf20Sopenharmony_ci	int (*reinit)(struct dao *dao, const struct dao_desc *desc);
748c2ecf20Sopenharmony_ci	int (*set_left_input)(struct dao *dao, struct rsc *input);
758c2ecf20Sopenharmony_ci	int (*set_right_input)(struct dao *dao, struct rsc *input);
768c2ecf20Sopenharmony_ci	int (*clear_left_input)(struct dao *dao);
778c2ecf20Sopenharmony_ci	int (*clear_right_input)(struct dao *dao);
788c2ecf20Sopenharmony_ci};
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_cistruct dai_rsc_ops {
818c2ecf20Sopenharmony_ci	int (*set_srt_srcl)(struct dai *dai, struct rsc *src);
828c2ecf20Sopenharmony_ci	int (*set_srt_srcr)(struct dai *dai, struct rsc *src);
838c2ecf20Sopenharmony_ci	int (*set_srt_msr)(struct dai *dai, unsigned int msr);
848c2ecf20Sopenharmony_ci	int (*set_enb_src)(struct dai *dai, unsigned int enb);
858c2ecf20Sopenharmony_ci	int (*set_enb_srt)(struct dai *dai, unsigned int enb);
868c2ecf20Sopenharmony_ci	int (*commit_write)(struct dai *dai);
878c2ecf20Sopenharmony_ci};
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci/* Define daio resource request description info */
908c2ecf20Sopenharmony_cistruct daio_desc {
918c2ecf20Sopenharmony_ci	unsigned int type:4;
928c2ecf20Sopenharmony_ci	unsigned int msr:4;
938c2ecf20Sopenharmony_ci	unsigned int passthru:1;
948c2ecf20Sopenharmony_ci};
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_cistruct daio_mgr {
978c2ecf20Sopenharmony_ci	struct rsc_mgr mgr;	/* Basic resource manager info */
988c2ecf20Sopenharmony_ci	struct snd_card *card;	/* pointer to this card */
998c2ecf20Sopenharmony_ci	spinlock_t mgr_lock;
1008c2ecf20Sopenharmony_ci	spinlock_t imap_lock;
1018c2ecf20Sopenharmony_ci	struct list_head imappers;
1028c2ecf20Sopenharmony_ci	struct imapper *init_imap;
1038c2ecf20Sopenharmony_ci	unsigned int init_imap_added;
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci	 /* request one daio resource */
1068c2ecf20Sopenharmony_ci	int (*get_daio)(struct daio_mgr *mgr,
1078c2ecf20Sopenharmony_ci			const struct daio_desc *desc, struct daio **rdaio);
1088c2ecf20Sopenharmony_ci	/* return one daio resource */
1098c2ecf20Sopenharmony_ci	int (*put_daio)(struct daio_mgr *mgr, struct daio *daio);
1108c2ecf20Sopenharmony_ci	int (*daio_enable)(struct daio_mgr *mgr, struct daio *daio);
1118c2ecf20Sopenharmony_ci	int (*daio_disable)(struct daio_mgr *mgr, struct daio *daio);
1128c2ecf20Sopenharmony_ci	int (*imap_add)(struct daio_mgr *mgr, struct imapper *entry);
1138c2ecf20Sopenharmony_ci	int (*imap_delete)(struct daio_mgr *mgr, struct imapper *entry);
1148c2ecf20Sopenharmony_ci	int (*commit_write)(struct daio_mgr *mgr);
1158c2ecf20Sopenharmony_ci};
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci/* Constructor and destructor of daio resource manager */
1188c2ecf20Sopenharmony_ciint daio_mgr_create(struct hw *hw, struct daio_mgr **rdaio_mgr);
1198c2ecf20Sopenharmony_ciint daio_mgr_destroy(struct daio_mgr *daio_mgr);
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci#endif /* CTDAIO_H */
122