Lines Matching +full:audio +full:- +full:core
1 // SPDX-License-Identifier: GPL-2.0-only
3 * MFD driver for wl1273 FM radio and audio codec submodules.
9 #include <linux/mfd/wl1273-core.h>
13 #define DRIVER_DESC "WL1273 FM Radio Core"
21 static int wl1273_fm_read_reg(struct wl1273_core *core, u8 reg, u16 *value) in wl1273_fm_read_reg() argument
23 struct i2c_client *client = core->client; in wl1273_fm_read_reg()
29 dev_err(&client->dev, "%s: Read: %d fails.\n", __func__, reg); in wl1273_fm_read_reg()
30 return -EREMOTEIO; in wl1273_fm_read_reg()
38 static int wl1273_fm_write_cmd(struct wl1273_core *core, u8 cmd, u16 param) in wl1273_fm_write_cmd() argument
40 struct i2c_client *client = core->client; in wl1273_fm_write_cmd()
46 dev_err(&client->dev, "%s: Cmd: %d fails.\n", __func__, cmd); in wl1273_fm_write_cmd()
53 static int wl1273_fm_write_data(struct wl1273_core *core, u8 *data, u16 len) in wl1273_fm_write_data() argument
55 struct i2c_client *client = core->client; in wl1273_fm_write_data()
59 msg.addr = client->addr; in wl1273_fm_write_data()
64 r = i2c_transfer(client->adapter, &msg, 1); in wl1273_fm_write_data()
66 dev_err(&client->dev, "%s: write error.\n", __func__); in wl1273_fm_write_data()
67 return -EREMOTEIO; in wl1273_fm_write_data()
74 * wl1273_fm_set_audio() - Set audio mode.
75 * @core: A pointer to the device struct.
76 * @new_mode: The new audio mode.
78 * Audio modes are WL1273_AUDIO_DIGITAL and WL1273_AUDIO_ANALOG.
80 static int wl1273_fm_set_audio(struct wl1273_core *core, unsigned int new_mode) in wl1273_fm_set_audio() argument
84 if (core->mode == WL1273_MODE_OFF || in wl1273_fm_set_audio()
85 core->mode == WL1273_MODE_SUSPENDED) in wl1273_fm_set_audio()
86 return -EPERM; in wl1273_fm_set_audio()
88 if (core->mode == WL1273_MODE_RX && new_mode == WL1273_AUDIO_DIGITAL) { in wl1273_fm_set_audio()
89 r = wl1273_fm_write_cmd(core, WL1273_PCM_MODE_SET, in wl1273_fm_set_audio()
94 r = wl1273_fm_write_cmd(core, WL1273_I2S_MODE_CONFIG_SET, in wl1273_fm_set_audio()
95 core->i2s_mode); in wl1273_fm_set_audio()
99 r = wl1273_fm_write_cmd(core, WL1273_AUDIO_ENABLE, in wl1273_fm_set_audio()
104 } else if (core->mode == WL1273_MODE_RX && in wl1273_fm_set_audio()
106 r = wl1273_fm_write_cmd(core, WL1273_AUDIO_ENABLE, in wl1273_fm_set_audio()
111 } else if (core->mode == WL1273_MODE_TX && in wl1273_fm_set_audio()
113 r = wl1273_fm_write_cmd(core, WL1273_I2S_MODE_CONFIG_SET, in wl1273_fm_set_audio()
114 core->i2s_mode); in wl1273_fm_set_audio()
118 r = wl1273_fm_write_cmd(core, WL1273_AUDIO_IO_SET, in wl1273_fm_set_audio()
123 } else if (core->mode == WL1273_MODE_TX && in wl1273_fm_set_audio()
125 r = wl1273_fm_write_cmd(core, WL1273_AUDIO_IO_SET, in wl1273_fm_set_audio()
131 core->audio_mode = new_mode; in wl1273_fm_set_audio()
137 * wl1273_fm_set_volume() - Set volume.
138 * @core: A pointer to the device struct.
141 static int wl1273_fm_set_volume(struct wl1273_core *core, unsigned int volume) in wl1273_fm_set_volume() argument
146 return -EINVAL; in wl1273_fm_set_volume()
148 if (core->volume == volume) in wl1273_fm_set_volume()
151 r = wl1273_fm_write_cmd(core, WL1273_VOLUME_SET, volume); in wl1273_fm_set_volume()
155 core->volume = volume; in wl1273_fm_set_volume()
161 struct wl1273_fm_platform_data *pdata = dev_get_platdata(&client->dev); in wl1273_core_probe()
162 struct wl1273_core *core; in wl1273_core_probe() local
167 dev_dbg(&client->dev, "%s\n", __func__); in wl1273_core_probe()
170 dev_err(&client->dev, "No platform data.\n"); in wl1273_core_probe()
171 return -EINVAL; in wl1273_core_probe()
174 if (!(pdata->children & WL1273_RADIO_CHILD)) { in wl1273_core_probe()
175 dev_err(&client->dev, "Cannot function without radio child.\n"); in wl1273_core_probe()
176 return -EINVAL; in wl1273_core_probe()
179 core = devm_kzalloc(&client->dev, sizeof(*core), GFP_KERNEL); in wl1273_core_probe()
180 if (!core) in wl1273_core_probe()
181 return -ENOMEM; in wl1273_core_probe()
183 core->pdata = pdata; in wl1273_core_probe()
184 core->client = client; in wl1273_core_probe()
185 mutex_init(&core->lock); in wl1273_core_probe()
187 i2c_set_clientdata(client, core); in wl1273_core_probe()
189 dev_dbg(&client->dev, "%s: Have V4L2.\n", __func__); in wl1273_core_probe()
191 cell = &core->cells[children]; in wl1273_core_probe()
192 cell->name = "wl1273_fm_radio"; in wl1273_core_probe()
193 cell->platform_data = &core; in wl1273_core_probe()
194 cell->pdata_size = sizeof(core); in wl1273_core_probe()
197 core->read = wl1273_fm_read_reg; in wl1273_core_probe()
198 core->write = wl1273_fm_write_cmd; in wl1273_core_probe()
199 core->write_data = wl1273_fm_write_data; in wl1273_core_probe()
200 core->set_audio = wl1273_fm_set_audio; in wl1273_core_probe()
201 core->set_volume = wl1273_fm_set_volume; in wl1273_core_probe()
203 if (pdata->children & WL1273_CODEC_CHILD) { in wl1273_core_probe()
204 cell = &core->cells[children]; in wl1273_core_probe()
206 dev_dbg(&client->dev, "%s: Have codec.\n", __func__); in wl1273_core_probe()
207 cell->name = "wl1273-codec"; in wl1273_core_probe()
208 cell->platform_data = &core; in wl1273_core_probe()
209 cell->pdata_size = sizeof(core); in wl1273_core_probe()
213 dev_dbg(&client->dev, "%s: number of children: %d.\n", in wl1273_core_probe()
216 r = devm_mfd_add_devices(&client->dev, -1, core->cells, in wl1273_core_probe()
224 pdata->free_resources(); in wl1273_core_probe()
226 dev_dbg(&client->dev, "%s\n", __func__); in wl1273_core_probe()