Lines Matching refs:kctl
198 * @kctl: the pointer with the control instance
205 struct snd_kcontrol *kctl, unsigned int ioff)
207 struct snd_ctl_elem_id id = kctl->id;
215 lops->lnotify(card, mask, kctl, ioff);
222 * @kctl: the pointer to store new control instance
233 static int snd_ctl_new(struct snd_kcontrol **kctl, unsigned int count,
241 *kctl = kzalloc(struct_size(*kctl, vd, count), GFP_KERNEL);
242 if (!*kctl)
246 (*kctl)->vd[idx].access = access;
247 (*kctl)->vd[idx].owner = file;
249 (*kctl)->count = count;
268 struct snd_kcontrol *kctl;
292 err = snd_ctl_new(&kctl, count, access, NULL);
297 kctl->id.iface = ncontrol->iface;
298 kctl->id.device = ncontrol->device;
299 kctl->id.subdevice = ncontrol->subdevice;
301 strscpy(kctl->id.name, ncontrol->name, sizeof(kctl->id.name));
302 if (strcmp(ncontrol->name, kctl->id.name) != 0)
304 ncontrol->name, kctl->id.name);
306 kctl->id.index = ncontrol->index;
308 kctl->info = ncontrol->info;
309 kctl->get = ncontrol->get;
310 kctl->put = ncontrol->put;
311 kctl->tlv.p = ncontrol->tlv.p;
313 kctl->private_value = ncontrol->private_value;
314 kctl->private_data = private_data;
316 return kctl;
341 struct snd_kcontrol *kctl;
347 list_for_each_entry(kctl, &card->controls, list) {
348 if (kctl->id.numid < card->last_numid + 1 + count &&
349 kctl->id.numid + kctl->count > card->last_numid + 1) {
350 card->last_numid = kctl->id.numid + kctl->count - 1;
371 /* check whether the given id is contained in the given kctl */
372 static bool elem_id_matches(const struct snd_kcontrol *kctl,
375 return kctl->id.iface == id->iface &&
376 kctl->id.device == id->device &&
377 kctl->id.subdevice == id->subdevice &&
378 !strncmp(kctl->id.name, id->name, sizeof(kctl->id.name)) &&
379 kctl->id.index <= id->index &&
380 kctl->id.index + kctl->count > id->index;
640 struct snd_kcontrol *kctl;
644 kctl = snd_ctl_find_id_locked(card, id);
645 if (kctl == NULL) {
649 ret = snd_ctl_remove_locked(card, kctl);
669 struct snd_kcontrol *kctl;
673 kctl = snd_ctl_find_id_locked(card, id);
674 if (kctl == NULL) {
678 if (!(kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_USER)) {
682 for (idx = 0; idx < kctl->count; idx++)
683 if (kctl->vd[idx].owner != NULL && kctl->vd[idx].owner != file) {
687 ret = snd_ctl_remove_locked(card, kctl);
708 struct snd_kcontrol *kctl;
714 kctl = snd_ctl_find_id_locked(card, id);
715 if (kctl == NULL) {
719 index_offset = snd_ctl_get_ioff(kctl, id);
720 vd = &kctl->vd[index_offset];
731 snd_ctl_build_ioff(id, kctl, index_offset);
733 snd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_INFO, kctl, index_offset);
764 struct snd_kcontrol *kctl;
768 kctl = snd_ctl_find_id_locked(card, src_id);
769 if (kctl == NULL) {
773 saved_numid = kctl->id.numid;
774 remove_hash_entries(card, kctl);
775 kctl->id = *dst_id;
776 kctl->id.numid = saved_numid;
777 add_hash_entries(card, kctl);
786 * @kctl: the control to rename
793 void snd_ctl_rename(struct snd_card *card, struct snd_kcontrol *kctl,
797 remove_hash_entries(card, kctl);
799 if (strscpy(kctl->id.name, name, sizeof(kctl->id.name)) < 0)
801 name, kctl->id.name);
803 add_hash_entries(card, kctl);
812 struct snd_kcontrol *kctl;
814 list_for_each_entry(kctl, &card->controls, list) {
815 if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid)
816 return kctl;
862 struct snd_kcontrol *kctl;
865 kctl = snd_ctl_find_numid_locked(card, numid);
867 return kctl;
886 struct snd_kcontrol *kctl;
894 kctl = xa_load(&card->ctl_hash, get_ctl_id_hash(id));
895 if (kctl && elem_id_matches(kctl, id))
896 return kctl;
901 list_for_each_entry(kctl, &card->controls, list)
902 if (elem_id_matches(kctl, id))
903 return kctl;
923 struct snd_kcontrol *kctl;
926 kctl = snd_ctl_find_id_locked(card, id);
928 return kctl;
960 struct snd_kcontrol *kctl;
972 list_for_each_entry(kctl, &card->controls, list) {
973 if (offset >= kctl->count) {
974 offset -= kctl->count;
977 for (jidx = offset; jidx < kctl->count; jidx++) {
978 snd_ctl_build_ioff(&id, kctl, jidx);
1013 /* Check whether the given kctl info is valid */
1200 struct snd_kcontrol *kctl,
1213 result = kctl->info(kctl, info);
1217 index_offset = snd_ctl_get_ioff(kctl, &info->id);
1218 vd = &kctl->vd[index_offset];
1219 snd_ctl_build_ioff(&info->id, kctl, index_offset);
1240 struct snd_kcontrol *kctl;
1244 kctl = snd_ctl_find_id_locked(card, &info->id);
1245 if (kctl == NULL)
1248 result = __snd_ctl_elem_info(card, kctl, info, ctl);
1275 struct snd_kcontrol *kctl;
1283 kctl = snd_ctl_find_id_locked(card, &control->id);
1284 if (kctl == NULL) {
1289 index_offset = snd_ctl_get_ioff(kctl, &control->id);
1290 vd = &kctl->vd[index_offset];
1291 if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_READ) || kctl->get == NULL) {
1296 snd_ctl_build_ioff(&control->id, kctl, index_offset);
1302 ret = __snd_ctl_elem_info(card, kctl, &info, NULL);
1311 ret = kctl->get(kctl, control);
1354 struct snd_kcontrol *kctl;
1360 kctl = snd_ctl_find_id_locked(card, &control->id);
1361 if (kctl == NULL) {
1366 index_offset = snd_ctl_get_ioff(kctl, &control->id);
1367 vd = &kctl->vd[index_offset];
1368 if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_WRITE) || kctl->put == NULL ||
1374 snd_ctl_build_ioff(&control->id, kctl, index_offset);
1382 result = __snd_ctl_elem_info(card, kctl, &info, NULL);
1388 result = kctl->put(kctl, control);
1397 snd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_VALUE, kctl, index_offset);
1434 struct snd_kcontrol *kctl;
1441 kctl = snd_ctl_find_id_locked(card, &id);
1442 if (kctl == NULL) {
1445 vd = &kctl->vd[snd_ctl_get_ioff(kctl, &id)];
1462 struct snd_kcontrol *kctl;
1469 kctl = snd_ctl_find_id_locked(card, &id);
1470 if (kctl == NULL) {
1473 vd = &kctl->vd[snd_ctl_get_ioff(kctl, &id)];
1569 static int replace_user_tlv(struct snd_kcontrol *kctl, unsigned int __user *buf,
1572 struct user_element *ue = kctl->private_data;
1601 for (i = 0; i < kctl->count; ++i)
1602 kctl->vd[i].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
1616 for (i = 0; i < kctl->count; ++i)
1617 snd_ctl_notify_one(ue->card, mask, kctl, i);
1622 static int read_user_tlv(struct snd_kcontrol *kctl, unsigned int __user *buf,
1625 struct user_element *ue = kctl->private_data;
1639 static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kctl, int op_flag,
1643 return replace_user_tlv(kctl, buf, size);
1645 return read_user_tlv(kctl, buf, size);
1712 struct snd_kcontrol *kctl;
1778 err = snd_ctl_new(&kctl, count, access, file);
1781 memcpy(&kctl->id, &info->id, sizeof(kctl->id));
1784 kfree(kctl);
1788 kctl->private_data = ue;
1789 kctl->private_free = snd_ctl_elem_user_free;
1803 snd_ctl_free_one(kctl);
1810 kctl->info = snd_ctl_elem_user_enum_info;
1812 kctl->info = snd_ctl_elem_user_info;
1814 kctl->get = snd_ctl_elem_user_get;
1816 kctl->put = snd_ctl_elem_user_put;
1818 kctl->tlv.c = snd_ctl_elem_user_tlv;
1821 err = __snd_ctl_add_replace(card, kctl, CTL_ADD_EXCLUSIVE);
1823 snd_ctl_free_one(kctl);
1826 offset = snd_ctl_get_ioff(kctl, &info->id);
1827 snd_ctl_build_ioff(&info->id, kctl, offset);
1891 struct snd_kcontrol *kctl,
1903 struct snd_kcontrol_volatile *vd = &kctl->vd[snd_ctl_get_ioff(kctl, id)];
1914 if (kctl->tlv.c == NULL)
1924 ret = kctl->tlv.c(kctl, op_flag, size, buf);
1929 static int read_tlv_buf(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id,
1932 struct snd_kcontrol_volatile *vd = &kctl->vd[snd_ctl_get_ioff(kctl, id)];
1938 if (kctl->tlv.p == NULL)
1941 len = sizeof(unsigned int) * 2 + kctl->tlv.p[1];
1945 if (copy_to_user(buf, kctl->tlv.p, len))
1958 struct snd_kcontrol *kctl;
1977 kctl = snd_ctl_find_numid_locked(file->card, header.numid);
1978 if (kctl == NULL)
1982 id = kctl->id;
1983 snd_ctl_build_ioff(&id, kctl, header.numid - id.numid);
1984 vd = &kctl->vd[snd_ctl_get_ioff(kctl, &id)];
1987 return call_tlv_handler(file, op_flag, kctl, &id, container,
1991 return read_tlv_buf(kctl, &id, container,
2257 struct snd_ctl_file *kctl;
2262 list_for_each_entry(kctl, &card->ctl_files, list) {
2263 if (kctl->pid == task_pid(current)) {
2264 subdevice = kctl->preferred_subdevice[type];