blob: a30be73b08ea6c4bb50cb5735d6fa7d0978d0a9d [file] [log] [blame]
Wai Yew CHAY8cc72362009-05-14 08:05:58 +02001/**
2 * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
3 *
4 * This source file is released under GPL v2 license (no other versions).
5 * See the COPYING file included in the main directory of this source
6 * distribution for the license terms and conditions.
7 *
8 * @File ctdaio.h
9 *
10 * @Brief
11 * This file contains the definition of Digital Audio Input Output
12 * resource management object.
13 *
14 * @Author Liu Chun
15 * @Date May 23 2008
16 *
17 */
18
19#ifndef CTDAIO_H
20#define CTDAIO_H
21
22#include "ctresource.h"
23#include "ctimap.h"
24#include <linux/spinlock.h>
25#include <linux/list.h>
Sudip Mukherjee3d0fdc82014-09-29 14:33:23 +053026#include <sound/core.h>
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020027
28/* Define the descriptor of a daio resource */
29enum DAIOTYP {
30 LINEO1,
31 LINEO2,
32 LINEO3,
33 LINEO4,
34 SPDIFOO, /* S/PDIF Out (Flexijack/Optical) */
35 LINEIM,
36 SPDIFIO, /* S/PDIF In (Flexijack/Optical) on the card */
Harry Butterworth55309212011-06-11 16:02:06 +080037 MIC, /* Dedicated mic on Titanium HD */
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020038 SPDIFI1, /* S/PDIF In on internal Drive Bay */
39 NUM_DAIOTYP
40};
41
42struct dao_rsc_ops;
43struct dai_rsc_ops;
44struct daio_mgr;
45
46struct daio {
47 struct rsc rscl; /* Basic resource info for left TX/RX */
48 struct rsc rscr; /* Basic resource info for right TX/RX */
49 enum DAIOTYP type;
50};
51
52struct dao {
53 struct daio daio;
Julia Lawall43f2cde2015-11-08 23:40:41 +010054 const struct dao_rsc_ops *ops; /* DAO specific operations */
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020055 struct imapper **imappers;
56 struct daio_mgr *mgr;
Sudip Mukherjee66640892014-09-29 14:33:21 +053057 struct hw *hw;
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020058 void *ctrl_blk;
59};
60
61struct dai {
62 struct daio daio;
Julia Lawall43f2cde2015-11-08 23:40:41 +010063 const struct dai_rsc_ops *ops; /* DAI specific operations */
Sudip Mukherjee66640892014-09-29 14:33:21 +053064 struct hw *hw;
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020065 void *ctrl_blk;
66};
67
68struct dao_desc {
69 unsigned int msr:4;
70 unsigned int passthru:1;
71};
72
73struct dao_rsc_ops {
74 int (*set_spos)(struct dao *dao, unsigned int spos);
75 int (*commit_write)(struct dao *dao);
76 int (*get_spos)(struct dao *dao, unsigned int *spos);
77 int (*reinit)(struct dao *dao, const struct dao_desc *desc);
78 int (*set_left_input)(struct dao *dao, struct rsc *input);
79 int (*set_right_input)(struct dao *dao, struct rsc *input);
80 int (*clear_left_input)(struct dao *dao);
81 int (*clear_right_input)(struct dao *dao);
82};
83
84struct dai_rsc_ops {
85 int (*set_srt_srcl)(struct dai *dai, struct rsc *src);
86 int (*set_srt_srcr)(struct dai *dai, struct rsc *src);
87 int (*set_srt_msr)(struct dai *dai, unsigned int msr);
88 int (*set_enb_src)(struct dai *dai, unsigned int enb);
89 int (*set_enb_srt)(struct dai *dai, unsigned int enb);
90 int (*commit_write)(struct dai *dai);
91};
92
93/* Define daio resource request description info */
94struct daio_desc {
95 unsigned int type:4;
96 unsigned int msr:4;
97 unsigned int passthru:1;
98};
99
100struct daio_mgr {
101 struct rsc_mgr mgr; /* Basic resource manager info */
Sudip Mukherjee3d0fdc82014-09-29 14:33:23 +0530102 struct snd_card *card; /* pointer to this card */
Wai Yew CHAY8cc72362009-05-14 08:05:58 +0200103 spinlock_t mgr_lock;
104 spinlock_t imap_lock;
105 struct list_head imappers;
106 struct imapper *init_imap;
107 unsigned int init_imap_added;
108
109 /* request one daio resource */
110 int (*get_daio)(struct daio_mgr *mgr,
111 const struct daio_desc *desc, struct daio **rdaio);
112 /* return one daio resource */
113 int (*put_daio)(struct daio_mgr *mgr, struct daio *daio);
114 int (*daio_enable)(struct daio_mgr *mgr, struct daio *daio);
115 int (*daio_disable)(struct daio_mgr *mgr, struct daio *daio);
116 int (*imap_add)(struct daio_mgr *mgr, struct imapper *entry);
117 int (*imap_delete)(struct daio_mgr *mgr, struct imapper *entry);
118 int (*commit_write)(struct daio_mgr *mgr);
119};
120
121/* Constructor and destructor of daio resource manager */
Sudip Mukherjee66640892014-09-29 14:33:21 +0530122int daio_mgr_create(struct hw *hw, struct daio_mgr **rdaio_mgr);
Wai Yew CHAY8cc72362009-05-14 08:05:58 +0200123int daio_mgr_destroy(struct daio_mgr *daio_mgr);
124
125#endif /* CTDAIO_H */