// SPDX-License-Identifier: GPL-2.0-only /* * MFD driver for wl1273 FM radio and audio codec submodules. * * Copyright (C) 2011 Nokia Corporation * Author: Matti Aaltonen <matti.j.aaltonen@nokia.com>
*/
r = i2c_transfer(client->adapter, &msg, 1); if (r != 1) {
dev_err(&client->dev, "%s: write error.\n", __func__); return -EREMOTEIO;
}
return 0;
}
/** * wl1273_fm_set_audio() - Set audio mode. * @core: A pointer to the device struct. * @new_mode: The new audio mode. * * Audio modes are WL1273_AUDIO_DIGITAL and WL1273_AUDIO_ANALOG.
*/ staticint wl1273_fm_set_audio(struct wl1273_core *core, unsignedint new_mode)
{ int r = 0;
if (core->mode == WL1273_MODE_OFF ||
core->mode == WL1273_MODE_SUSPENDED) return -EPERM;
if (core->mode == WL1273_MODE_RX && new_mode == WL1273_AUDIO_DIGITAL) {
r = wl1273_fm_write_cmd(core, WL1273_PCM_MODE_SET,
WL1273_PCM_DEF_MODE); if (r) goto out;
r = wl1273_fm_write_cmd(core, WL1273_I2S_MODE_CONFIG_SET,
core->i2s_mode); if (r) goto out;
r = wl1273_fm_write_cmd(core, WL1273_AUDIO_ENABLE,
WL1273_AUDIO_ENABLE_I2S); if (r) goto out;
} elseif (core->mode == WL1273_MODE_RX &&
new_mode == WL1273_AUDIO_ANALOG) {
r = wl1273_fm_write_cmd(core, WL1273_AUDIO_ENABLE,
WL1273_AUDIO_ENABLE_ANALOG); if (r) goto out;
} elseif (core->mode == WL1273_MODE_TX &&
new_mode == WL1273_AUDIO_DIGITAL) {
r = wl1273_fm_write_cmd(core, WL1273_I2S_MODE_CONFIG_SET,
core->i2s_mode); if (r) goto out;
r = wl1273_fm_write_cmd(core, WL1273_AUDIO_IO_SET,
WL1273_AUDIO_IO_SET_I2S); if (r) goto out;
} elseif (core->mode == WL1273_MODE_TX &&
new_mode == WL1273_AUDIO_ANALOG) {
r = wl1273_fm_write_cmd(core, WL1273_AUDIO_IO_SET,
WL1273_AUDIO_IO_SET_ANALOG); if (r) goto out;
}
core->audio_mode = new_mode;
out: return r;
}
/** * wl1273_fm_set_volume() - Set volume. * @core: A pointer to the device struct. * @volume: The new volume value.
*/ staticint wl1273_fm_set_volume(struct wl1273_core *core, unsignedint volume)
{ int r;
if (volume > WL1273_MAX_VOLUME) return -EINVAL;
if (core->volume == volume) return 0;
r = wl1273_fm_write_cmd(core, WL1273_VOLUME_SET, volume); if (r) return r;
core->volume = volume; return 0;
}
staticint wl1273_core_probe(struct i2c_client *client)
{ struct wl1273_fm_platform_data *pdata = dev_get_platdata(&client->dev); struct wl1273_core *core; struct mfd_cell *cell; int children = 0; int r = 0;
dev_dbg(&client->dev, "%s\n", __func__);
if (!pdata) {
dev_err(&client->dev, "No platform data.\n"); return -EINVAL;
}
if (!(pdata->children & WL1273_RADIO_CHILD)) {
dev_err(&client->dev, "Cannot function without radio child.\n"); return -EINVAL;
}
core = devm_kzalloc(&client->dev, sizeof(*core), GFP_KERNEL); if (!core) return -ENOMEM;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.