95a391ff0627b2c8e10969a9c6f6c72b3bf8a652
4 * Copyright (C) 2013 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
14 #include <linux/clk.h>
15 #include <linux/device.h>
17 #include <linux/list.h>
18 #include <linux/module.h>
19 #include <sound/rcar_snd.h>
20 #include <sound/soc.h>
21 #include <sound/pcm_params.h>
26 * The register address offsets SRU/SCU/SSIU on Gen1/Gen2 are very different.
27 * This driver uses pseudo register in order to hide it.
28 * see gen1/gen2 for detail
41 struct rsnd_dai_stream
;
44 * R-Car basic functions
46 #define rsnd_mod_read(m, r) \
47 rsnd_read(rsnd_mod_to_priv(m), m, RSND_REG_##r)
48 #define rsnd_mod_write(m, r, d) \
49 rsnd_write(rsnd_mod_to_priv(m), m, RSND_REG_##r, d)
50 #define rsnd_mod_bset(m, r, s, d) \
51 rsnd_bset(rsnd_mod_to_priv(m), m, RSND_REG_##r, s, d)
53 #define rsnd_priv_read(p, r) rsnd_read(p, NULL, RSND_REG_##r)
54 #define rsnd_priv_write(p, r, d) rsnd_write(p, NULL, RSND_REG_##r, d)
55 #define rsnd_priv_bset(p, r, s, d) rsnd_bset(p, NULL, RSND_REG_##r, s, d)
57 u32
rsnd_read(struct rsnd_priv
*priv
, struct rsnd_mod
*mod
, enum rsnd_reg reg
);
58 void rsnd_write(struct rsnd_priv
*priv
, struct rsnd_mod
*mod
,
59 enum rsnd_reg reg
, u32 data
);
60 void rsnd_bset(struct rsnd_priv
*priv
, struct rsnd_mod
*mod
, enum rsnd_reg reg
,
69 int (*init
)(struct rsnd_mod
*mod
,
70 struct rsnd_dai
*rdai
,
71 struct rsnd_dai_stream
*io
);
72 int (*quit
)(struct rsnd_mod
*mod
,
73 struct rsnd_dai
*rdai
,
74 struct rsnd_dai_stream
*io
);
75 int (*start
)(struct rsnd_mod
*mod
,
76 struct rsnd_dai
*rdai
,
77 struct rsnd_dai_stream
*io
);
78 int (*stop
)(struct rsnd_mod
*mod
,
79 struct rsnd_dai
*rdai
,
80 struct rsnd_dai_stream
*io
);
85 struct rsnd_priv
*priv
;
86 struct rsnd_mod_ops
*ops
;
87 struct list_head list
; /* connect to rsnd_dai playback/capture */
90 #define rsnd_mod_to_priv(mod) ((mod)->priv)
91 #define rsnd_mod_id(mod) ((mod)->id)
92 #define for_each_rsnd_mod(pos, n, io) \
93 list_for_each_entry_safe(pos, n, &(io)->head, list)
94 #define rsnd_mod_call(mod, func, rdai, io) \
96 !((mod)->ops->func) ? 0 : \
97 (mod)->ops->func(mod, rdai, io))
99 void rsnd_mod_init(struct rsnd_priv
*priv
,
100 struct rsnd_mod
*mod
,
101 struct rsnd_mod_ops
*ops
,
103 char *rsnd_mod_name(struct rsnd_mod
*mod
);
108 #define RSND_DAI_NAME_SIZE 16
109 struct rsnd_dai_stream
{
110 struct list_head head
; /* head of rsnd_mod list */
111 struct snd_pcm_substream
*substream
;
115 int next_period_byte
;
119 char name
[RSND_DAI_NAME_SIZE
];
120 struct rsnd_dai_platform_info
*info
; /* rcar_snd.h */
121 struct rsnd_dai_stream playback
;
122 struct rsnd_dai_stream capture
;
128 int data_alignment
:1;
131 #define rsnd_dai_nr(priv) ((priv)->dai_nr)
132 #define for_each_rsnd_dai(rdai, priv, i) \
133 for (i = 0, (rdai) = rsnd_dai_get(priv, i); \
134 i < rsnd_dai_nr(priv); \
135 i++, (rdai) = rsnd_dai_get(priv, i))
137 struct rsnd_dai
*rsnd_dai_get(struct rsnd_priv
*priv
, int id
);
138 int rsnd_dai_disconnect(struct rsnd_mod
*mod
);
139 int rsnd_dai_connect(struct rsnd_dai
*rdai
, struct rsnd_mod
*mod
,
140 struct rsnd_dai_stream
*io
);
141 int rsnd_dai_is_play(struct rsnd_dai
*rdai
, struct rsnd_dai_stream
*io
);
142 #define rsnd_dai_get_platform_info(rdai) ((rdai)->info)
144 void rsnd_dai_pointer_update(struct rsnd_dai_stream
*io
, int cnt
);
145 int rsnd_dai_pointer_offset(struct rsnd_dai_stream
*io
, int additional
);
150 int rsnd_gen_probe(struct platform_device
*pdev
,
151 struct rcar_snd_info
*info
,
152 struct rsnd_priv
*priv
);
153 void rsnd_gen_remove(struct platform_device
*pdev
,
154 struct rsnd_priv
*priv
);
155 int rsnd_gen_path_init(struct rsnd_priv
*priv
,
156 struct rsnd_dai
*rdai
,
157 struct rsnd_dai_stream
*io
);
158 int rsnd_gen_path_exit(struct rsnd_priv
*priv
,
159 struct rsnd_dai
*rdai
,
160 struct rsnd_dai_stream
*io
);
161 void __iomem
*rsnd_gen_reg_get(struct rsnd_priv
*priv
,
162 struct rsnd_mod
*mod
,
171 struct rcar_snd_info
*info
;
175 * below value will be filled on rsnd_gen_probe()
180 * below value will be filled on rsnd_scu_probe()
186 * below value will be filled on rsnd_dai_probe()
188 struct snd_soc_dai_driver
*daidrv
;
189 struct rsnd_dai
*rdai
;
193 #define rsnd_priv_to_dev(priv) ((priv)->dev)
194 #define rsnd_lock(priv, flags) spin_lock_irqsave(&priv->lock, flags)
195 #define rsnd_unlock(priv, flags) spin_unlock_irqrestore(&priv->lock, flags)
200 int rsnd_scu_probe(struct platform_device
*pdev
,
201 struct rcar_snd_info
*info
,
202 struct rsnd_priv
*priv
);
203 void rsnd_scu_remove(struct platform_device
*pdev
,
204 struct rsnd_priv
*priv
);
205 struct rsnd_mod
*rsnd_scu_mod_get(struct rsnd_priv
*priv
, int id
);
206 #define rsnd_scu_nr(priv) ((priv)->scu_nr)
This page took 0.064015 seconds and 4 git commands to generate.