int (*manifest)(struct snd_soc_component *,
struct snd_soc_tplg_manifest *);
----- /* bespoke kcontrol handlers available for binding */
+++++ /* vendor specific kcontrol handlers available for binding */
const struct snd_soc_tplg_kcontrol_ops *io_ops;
int io_ops_count;
+++++
+++++ /* vendor specific bytes ext handlers available for binding */
+++++ const struct snd_soc_tplg_bytes_ext_ops *bytes_ext_ops;
+++++ int bytes_ext_ops_count;
};
+++++#ifdef CONFIG_SND_SOC_TOPOLOGY
+++++
/* gets a pointer to data from the firmware block header */
static inline const void *snd_soc_tplg_get_data(struct snd_soc_tplg_hdr *hdr)
{
i2c_set_clientdata(client, max9768);
max9768->regmap = devm_regmap_init_i2c(client, &max9768_i2c_regmap_config);
----- if (IS_ERR(max9768->regmap)) {
----- err = PTR_ERR(max9768->regmap);
----- goto err_gpio_free;
----- }
-
- err = snd_soc_register_codec(&client->dev, &max9768_codec_driver, NULL, 0);
- if (err)
- goto err_gpio_free;
-
- return 0;
-
- err_gpio_free:
- if (gpio_is_valid(max9768->shdn_gpio))
- gpio_free(max9768->shdn_gpio);
- if (gpio_is_valid(max9768->mute_gpio))
- gpio_free(max9768->mute_gpio);
-
- return err;
- }
-
- static int max9768_i2c_remove(struct i2c_client *client)
- {
- struct max9768 *max9768 = i2c_get_clientdata(client);
+++++ if (IS_ERR(max9768->regmap))
+++++ return PTR_ERR(max9768->regmap);
--- - err = snd_soc_register_codec(&client->dev, &max9768_codec_driver, NULL, 0);
--- - if (err)
--- - goto err_gpio_free;
--- -
--- - return 0;
--- -
--- - err_gpio_free:
--- - if (gpio_is_valid(max9768->shdn_gpio))
--- - gpio_free(max9768->shdn_gpio);
--- - if (gpio_is_valid(max9768->mute_gpio))
--- - gpio_free(max9768->mute_gpio);
--- -
--- - return err;
--- -}
--- -
--- -static int max9768_i2c_remove(struct i2c_client *client)
--- -{
--- - struct max9768 *max9768 = i2c_get_clientdata(client);
--- -
----- snd_soc_unregister_codec(&client->dev);
-----
----- if (gpio_is_valid(max9768->shdn_gpio))
----- gpio_free(max9768->shdn_gpio);
----- if (gpio_is_valid(max9768->mute_gpio))
----- gpio_free(max9768->mute_gpio);
-----
----- return 0;
+++++ return devm_snd_soc_register_component(&client->dev,
+++++ &max9768_component_driver, NULL, 0);
}
static const struct i2c_device_id max9768_i2c_id[] = {
{
struct rt5645_priv *rt5645 =
container_of(work, struct rt5645_priv, jack_detect_work.work);
-----
----- rt5645_irq_detection(rt5645);
-----}
-----
-----static irqreturn_t rt5645_irq(int irq, void *data)
-----{
----- struct rt5645_priv *rt5645 = data;
-----
----- queue_delayed_work(system_power_efficient_wq,
----- &rt5645->jack_detect_work, msecs_to_jiffies(250));
-----
----- return IRQ_HANDLED;
-----}
-----
-----static int rt5645_button_detect(struct snd_soc_codec *codec)
-----{
----- int btn_type, val;
-----
----- val = snd_soc_read(codec, RT5650_4BTN_IL_CMD1);
----- pr_debug("val=0x%x\n", val);
----- btn_type = val & 0xfff0;
----- snd_soc_write(codec, RT5650_4BTN_IL_CMD1, val);
-----
----- return btn_type;
-----}
-----
-----static int rt5645_irq_detection(struct rt5645_priv *rt5645)
-----{
int val, btn_type, gpio_state = 0, report = 0;
- return -EINVAL;
++++ if (!rt5645->codec)
+++++ return;
++++
switch (rt5645->pdata.jd_mode) {
case 0: /* Not using rt5645 JD */
if (rt5645->gpiod_hp_det) {
if (k->put && k->get && k->info)
return 0;
----- /* none found so try bespoke handlers */
----- for (i = 0; i < num_bops; i++) {
+++++ /* none found so try standard kcontrol handlers */
+++++ ops = io_ops;
+++++ num_ops = ARRAY_SIZE(io_ops);
+++++ for (i = 0; i < num_ops; i++) {
----- if (k->put == NULL && bops[i].id == hdr->ops.put)
----- k->put = bops[i].put;
----- if (k->get == NULL && bops[i].id == hdr->ops.get)
----- k->get = bops[i].get;
- if (k->info == NULL && bops[i].id == hdr->ops.info)
- k->info = bops[i].info;
+++++ if (k->put == NULL && ops[i].id == hdr->ops.put)
+++++ k->put = ops[i].put;
+++++ if (k->get == NULL && ops[i].id == hdr->ops.get)
+++++ k->get = ops[i].get;
+ if (k->info == NULL && ops[i].id == hdr->ops.info)
---- k->info = bops[i].info;
+++++ k->info = ops[i].info;
}
----- /* bespoke handlers found ? */
+++++ /* standard handlers found ? */
if (k->put && k->get && k->info)
return 0;
return 0;
}
++++
++++ static int soc_tplg_create_tlv_db_scale(struct soc_tplg *tplg,
++++ struct snd_kcontrol_new *kc, struct snd_soc_tplg_tlv_dbscale *scale)
++++ {
++++ unsigned int item_len = 2 * sizeof(unsigned int);
++++ unsigned int *p;
++++
++++ p = kzalloc(item_len + 2 * sizeof(unsigned int), GFP_KERNEL);
++++ if (!p)
++++ return -ENOMEM;
++++
++++ p[0] = SNDRV_CTL_TLVT_DB_SCALE;
++++ p[1] = item_len;
++++ p[2] = scale->min;
++++ p[3] = (scale->step & TLV_DB_SCALE_MASK)
++++ | (scale->mute ? TLV_DB_SCALE_MUTE : 0);
++++
++++ kc->tlv.p = (void *)p;
++++ return 0;
++++ }
++++
static int soc_tplg_create_tlv(struct soc_tplg *tplg,
---- struct snd_kcontrol_new *kc, u32 tlv_size)
++++ struct snd_kcontrol_new *kc, struct snd_soc_tplg_ctl_hdr *tc)
{
struct snd_soc_tplg_ctl_tlv *tplg_tlv;
---- struct snd_ctl_tlv *tlv;
---- if (tlv_size == 0)
++++ if (!(tc->access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE))
return 0;
- if (tc->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) {
- kc->tlv.c = snd_soc_bytes_tlv_callback;
- } else {
---- tplg_tlv = (struct snd_soc_tplg_ctl_tlv *) tplg->pos;
---- tplg->pos += tlv_size;
----
---- tlv = kzalloc(sizeof(*tlv) + tlv_size, GFP_KERNEL);
---- if (tlv == NULL)
---- return -ENOMEM;
----
---- dev_dbg(tplg->dev, " created TLV type %d size %d bytes\n",
---- tplg_tlv->numid, tplg_tlv->size);
+++++ if (!(tc->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK)) {
++++ tplg_tlv = &tc->tlv;
++++ switch (tplg_tlv->type) {
++++ case SNDRV_CTL_TLVT_DB_SCALE:
++++ return soc_tplg_create_tlv_db_scale(tplg, kc,
++++ &tplg_tlv->scale);
---- tlv->numid = tplg_tlv->numid;
---- tlv->length = tplg_tlv->size;
---- memcpy(tlv->tlv, tplg_tlv + 1, tplg_tlv->size);
---- kc->tlv.p = (void *)tlv;
++++ /* TODO: add support for other TLV types */
++++ default:
++++ dev_dbg(tplg->dev, "Unsupported TLV type %d\n",
++++ tplg_tlv->type);
++++ return -EINVAL;
++++ }
++++ }
return 0;
}