^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 ctdaio.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 Digital Audio Input Output
^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 23 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 CTDAIO_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define CTDAIO_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 "ctimap.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) /* Define the descriptor of a daio resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) enum DAIOTYP {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) LINEO1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) LINEO2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) LINEO3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) LINEO4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) SPDIFOO, /* S/PDIF Out (Flexijack/Optical) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) LINEIM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) SPDIFIO, /* S/PDIF In (Flexijack/Optical) on the card */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) MIC, /* Dedicated mic on Titanium HD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) SPDIFI1, /* S/PDIF In on internal Drive Bay */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) NUM_DAIOTYP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct dao_rsc_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct dai_rsc_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct daio_mgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct daio {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct rsc rscl; /* Basic resource info for left TX/RX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct rsc rscr; /* Basic resource info for right TX/RX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) enum DAIOTYP type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct dao {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct daio daio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) const struct dao_rsc_ops *ops; /* DAO specific operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct imapper **imappers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct daio_mgr *mgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct hw *hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) void *ctrl_blk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct dai {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct daio daio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) const struct dai_rsc_ops *ops; /* DAI specific operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct hw *hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) void *ctrl_blk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct dao_desc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) unsigned int msr:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) unsigned int passthru:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct dao_rsc_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) int (*set_spos)(struct dao *dao, unsigned int spos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) int (*commit_write)(struct dao *dao);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int (*get_spos)(struct dao *dao, unsigned int *spos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) int (*reinit)(struct dao *dao, const struct dao_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) int (*set_left_input)(struct dao *dao, struct rsc *input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) int (*set_right_input)(struct dao *dao, struct rsc *input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) int (*clear_left_input)(struct dao *dao);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) int (*clear_right_input)(struct dao *dao);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct dai_rsc_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) int (*set_srt_srcl)(struct dai *dai, struct rsc *src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) int (*set_srt_srcr)(struct dai *dai, struct rsc *src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) int (*set_srt_msr)(struct dai *dai, unsigned int msr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) int (*set_enb_src)(struct dai *dai, unsigned int enb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) int (*set_enb_srt)(struct dai *dai, unsigned int enb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) int (*commit_write)(struct dai *dai);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /* Define daio resource request description info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) struct daio_desc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) unsigned int type:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) unsigned int msr:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) unsigned int passthru:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) struct daio_mgr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct rsc_mgr mgr; /* Basic resource manager info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct snd_card *card; /* pointer to this card */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) spinlock_t mgr_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) spinlock_t imap_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct list_head imappers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct imapper *init_imap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) unsigned int init_imap_added;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) /* request one daio resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) int (*get_daio)(struct daio_mgr *mgr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) const struct daio_desc *desc, struct daio **rdaio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /* return one daio resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) int (*put_daio)(struct daio_mgr *mgr, struct daio *daio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int (*daio_enable)(struct daio_mgr *mgr, struct daio *daio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) int (*daio_disable)(struct daio_mgr *mgr, struct daio *daio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) int (*imap_add)(struct daio_mgr *mgr, struct imapper *entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) int (*imap_delete)(struct daio_mgr *mgr, struct imapper *entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int (*commit_write)(struct daio_mgr *mgr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) /* Constructor and destructor of daio resource manager */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) int daio_mgr_create(struct hw *hw, struct daio_mgr **rdaio_mgr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) int daio_mgr_destroy(struct daio_mgr *daio_mgr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #endif /* CTDAIO_H */