Changeset 750
- Timestamp:
- Oct 3, 2022, 4:24:46 AM (3 years ago)
- Location:
- GPL/branches/uniaud32-exp
- Files:
-
- 1 added
- 45 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/uniaud32-exp/alsa-kernel/core/control.c
r739 r750 161 161 return; 162 162 read_lock_irqsave(&card->ctl_files_rwlock, flags); 163 #if IS_ENABLED(CONFIG_SND_MIXER_OSS) 163 //#if (IS_ENABLED(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS)) 164 #if defined(CONFIG_SND_MIXER_OSS) 164 165 card->mixer_oss_change_count++; 165 166 #endif … … 378 379 } 379 380 381 /* check whether the given id is contained in the given kctl */ 382 static bool elem_id_matches(const struct snd_kcontrol *kctl, 383 const struct snd_ctl_elem_id *id) 384 { 385 return kctl->id.iface == id->iface && 386 kctl->id.device == id->device && 387 kctl->id.subdevice == id->subdevice && 388 !strncmp(kctl->id.name, id->name, sizeof(kctl->id.name)) && 389 kctl->id.index <= id->index && 390 kctl->id.index + kctl->count > id->index; 391 } 392 393 #ifdef CONFIG_SND_CTL_FAST_LOOKUP 394 /* Compute a hash key for the corresponding ctl id 395 * It's for the name lookup, hence the numid is excluded. 396 * The hash key is bound in LONG_MAX to be used for Xarray key. 397 */ 398 #define MULTIPLIER 37 399 static unsigned long get_ctl_id_hash(const struct snd_ctl_elem_id *id) 400 { 401 int i; 402 unsigned long h; 403 404 h = id->iface; 405 h = MULTIPLIER * h + id->device; 406 h = MULTIPLIER * h + id->subdevice; 407 for (i = 0; i < SNDRV_CTL_ELEM_ID_NAME_MAXLEN && id->name[i]; i++) 408 h = MULTIPLIER * h + id->name[i]; 409 h = MULTIPLIER * h + id->index; 410 h &= LONG_MAX; 411 return h; 412 } 413 414 /* add hash entries to numid and ctl xarray tables */ 415 static void add_hash_entries(struct snd_card *card, 416 struct snd_kcontrol *kcontrol) 417 { 418 struct snd_ctl_elem_id id = kcontrol->id; 419 int i; 420 421 xa_store_range(&card->ctl_numids, kcontrol->id.numid, 422 kcontrol->id.numid + kcontrol->count - 1, 423 kcontrol, GFP_KERNEL); 424 425 for (i = 0; i < kcontrol->count; i++) { 426 id.index = kcontrol->id.index + i; 427 if (xa_insert(&card->ctl_hash, get_ctl_id_hash(&id), 428 kcontrol, GFP_KERNEL)) { 429 /* skip hash for this entry, noting we had collision */ 430 card->ctl_hash_collision = true; 431 dev_dbg(card->dev, "ctl_hash collision %d:%s:%d\n", 432 id.iface, id.name, id.index); 433 } 434 } 435 } 436 437 /* remove hash entries that have been added */ 438 static void remove_hash_entries(struct snd_card *card, 439 struct snd_kcontrol *kcontrol) 440 { 441 struct snd_ctl_elem_id id = kcontrol->id; 442 struct snd_kcontrol *matched; 443 unsigned long h; 444 int i; 445 446 for (i = 0; i < kcontrol->count; i++) { 447 xa_erase(&card->ctl_numids, id.numid); 448 h = get_ctl_id_hash(&id); 449 matched = xa_load(&card->ctl_hash, h); 450 if (matched && (matched == kcontrol || 451 elem_id_matches(matched, &id))) 452 xa_erase(&card->ctl_hash, h); 453 id.index++; 454 id.numid++; 455 } 456 } 457 #else /* CONFIG_SND_CTL_FAST_LOOKUP */ 458 static inline void add_hash_entries(struct snd_card *card, 459 struct snd_kcontrol *kcontrol) 460 { 461 } 462 static inline void remove_hash_entries(struct snd_card *card, 463 struct snd_kcontrol *kcontrol) 464 { 465 } 466 #endif /* CONFIG_SND_CTL_FAST_LOOKUP */ 467 380 468 enum snd_ctl_add_mode { 381 469 CTL_ADD_EXCLUSIVE, CTL_REPLACE, CTL_ADD_ON_REPLACE, … … 422 510 card->last_numid += kcontrol->count; 423 511 512 add_hash_entries(card, kcontrol); 513 424 514 for (idx = 0; idx < kcontrol->count; idx++) 425 515 snd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_ADD, kcontrol, idx); … … 493 583 EXPORT_SYMBOL(snd_ctl_replace); 494 584 585 static int __snd_ctl_remove(struct snd_card *card, 586 struct snd_kcontrol *kcontrol, 587 bool remove_hash) 588 { 589 unsigned int idx; 590 591 if (snd_BUG_ON(!card || !kcontrol)) 592 return -EINVAL; 593 list_del(&kcontrol->list); 594 595 if (remove_hash) 596 remove_hash_entries(card, kcontrol); 597 598 card->controls_count -= kcontrol->count; 599 for (idx = 0; idx < kcontrol->count; idx++) 600 snd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_REMOVE, kcontrol, idx); 601 snd_ctl_free_one(kcontrol); 602 return 0; 603 } 604 495 605 /** 496 606 * snd_ctl_remove - remove the control from the card and release it … … 506 616 int snd_ctl_remove(struct snd_card *card, struct snd_kcontrol *kcontrol) 507 617 { 508 unsigned int idx; 509 510 if (snd_BUG_ON(!card || !kcontrol)) 511 return -EINVAL; 512 list_del(&kcontrol->list); 513 card->controls_count -= kcontrol->count; 514 for (idx = 0; idx < kcontrol->count; idx++) 515 snd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_REMOVE, kcontrol, idx); 516 snd_ctl_free_one(kcontrol); 517 return 0; 618 return __snd_ctl_remove(card, kcontrol, true); 518 619 } 519 620 EXPORT_SYMBOL(snd_ctl_remove); … … 656 757 return -ENOENT; 657 758 } 759 remove_hash_entries(card, kctl); 658 760 kctl->id = *dst_id; 659 761 kctl->id.numid = card->last_numid + 1; 660 762 card->last_numid += kctl->count; 763 add_hash_entries(card, kctl); 661 764 up_write(&card->controls_rwsem); 662 765 return 0; 663 766 } 664 767 EXPORT_SYMBOL(snd_ctl_rename_id); 768 769 #ifndef CONFIG_SND_CTL_FAST_LOOKUP 770 static struct snd_kcontrol * 771 snd_ctl_find_numid_slow(struct snd_card *card, unsigned int numid) 772 { 773 struct snd_kcontrol *kctl; 774 775 list_for_each_entry(kctl, &card->controls, list, struct snd_kcontrol) { 776 if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid) 777 return kctl; 778 } 779 return NULL; 780 } 781 #endif /* !CONFIG_SND_CTL_FAST_LOOKUP */ 665 782 666 783 /** … … 679 796 struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numid) 680 797 { 681 struct snd_kcontrol *kctl;682 683 798 if (snd_BUG_ON(!card || !numid)) 684 799 return NULL; 685 list_for_each_entry(kctl, &card->controls, list, struct snd_kcontrol) { 686 if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid)687 return kctl; 688 }689 return NULL; 800 #ifdef CONFIG_SND_CTL_FAST_LOOKUP 801 return xa_load(&card->ctl_numids, numid); 802 #else 803 return snd_ctl_find_numid_slow(card, numid); 804 #endif 690 805 } 691 806 EXPORT_SYMBOL(snd_ctl_find_numid); … … 713 828 if (id->numid != 0) 714 829 return snd_ctl_find_numid(card, id->numid); 715 list_for_each_entry(kctl, &card->controls, list, struct snd_kcontrol) { 716 if (kctl->id.iface != id->iface) 717 continue; 718 if (kctl->id.device != id->device) 719 continue; 720 if (kctl->id.subdevice != id->subdevice) 721 continue; 722 if (strncmp(kctl->id.name, id->name, sizeof(kctl->id.name))) 723 continue; 724 if (kctl->id.index > id->index) 725 continue; 726 if (kctl->id.index + kctl->count <= id->index) 727 continue; 830 #ifdef CONFIG_SND_CTL_FAST_LOOKUP 831 kctl = xa_load(&card->ctl_hash, get_ctl_id_hash(id)); 832 if (kctl && elem_id_matches(kctl, id)) 728 833 return kctl; 729 } 834 if (!card->ctl_hash_collision) 835 return NULL; /* we can rely on only hash table */ 836 #endif 837 /* no matching in hash table - try all as the last resort */ 838 list_for_each_entry(kctl, &card->controls, list, struct snd_kcontrol) 839 if (elem_id_matches(kctl, id)) 840 return kctl; 730 841 return NULL; 731 842 } … … 869 980 }; 870 981 871 #ifdef CONFIG_SND_CTL_VALIDATION872 982 /* fill the remaining snd_ctl_elem_value data with the given pattern */ 873 983 static void fill_remaining_elem_value(struct snd_ctl_elem_value *control, … … 886 996 const struct snd_ctl_elem_value *control, 887 997 const struct snd_ctl_elem_info *info, 888 int i )998 int i, bool print_error) 889 999 { 890 1000 long long lval, lmin, lmax, lstep; … … 920 1030 921 1031 if (lval < lmin || lval > lmax) { 922 dev_err(card->dev, 923 "control %i:%i:%i:%s:%i: value out of range %lld (%lld/%lld) at count %i\n", 924 control->id.iface, control->id.device, 925 control->id.subdevice, control->id.name, 926 control->id.index, lval, lmin, lmax, i); 1032 if (print_error) 1033 dev_err(card->dev, 1034 "control %i:%i:%i:%s:%i: value out of range %lld (%lld/%lld) at count %i\n", 1035 control->id.iface, control->id.device, 1036 control->id.subdevice, control->id.name, 1037 control->id.index, lval, lmin, lmax, i); 927 1038 return -EINVAL; 928 1039 } … … 930 1041 div64_u64_rem(lval, lstep, &rem); 931 1042 if (rem) { 932 dev_err(card->dev, 933 "control %i:%i:%i:%s:%i: unaligned value %lld (step %lld) at count %i\n", 934 control->id.iface, control->id.device, 935 control->id.subdevice, control->id.name, 936 control->id.index, lval, lstep, i); 1043 if (print_error) 1044 dev_err(card->dev, 1045 "control %i:%i:%i:%s:%i: unaligned value %lld (step %lld) at count %i\n", 1046 control->id.iface, control->id.device, 1047 control->id.subdevice, control->id.name, 1048 control->id.index, lval, lstep, i); 937 1049 return -EINVAL; 938 1050 } … … 942 1054 } 943 1055 944 /* perform sanity checks to the given snd_ctl_elem_value object */ 945 static int sanity_check_elem_value(struct snd_card *card, 946 const struct snd_ctl_elem_value *control, 947 const struct snd_ctl_elem_info *info, 948 u32 pattern) 949 { 950 size_t offset; 951 int i, ret = 0; 952 u32 *p; 1056 /* check whether the all input values are valid for the given elem value */ 1057 static int sanity_check_input_values(struct snd_card *card, 1058 const struct snd_ctl_elem_value *control, 1059 const struct snd_ctl_elem_info *info, 1060 bool print_error) 1061 { 1062 int i, ret; 953 1063 954 1064 switch (info->type) { … … 958 1068 case SNDRV_CTL_ELEM_TYPE_ENUMERATED: 959 1069 for (i = 0; i < info->count; i++) { 960 ret = sanity_check_int_value(card, control, info, i); 1070 ret = sanity_check_int_value(card, control, info, i, 1071 print_error); 961 1072 if (ret < 0) 962 1073 return ret; … … 966 1077 break; 967 1078 } 1079 1080 return 0; 1081 } 1082 1083 /* perform sanity checks to the given snd_ctl_elem_value object */ 1084 static int sanity_check_elem_value(struct snd_card *card, 1085 const struct snd_ctl_elem_value *control, 1086 const struct snd_ctl_elem_info *info, 1087 u32 pattern) 1088 { 1089 size_t offset; 1090 int ret; 1091 u32 *p; 1092 1093 ret = sanity_check_input_values(card, control, info, true); 1094 if (ret < 0) 1095 return ret; 968 1096 969 1097 /* check whether the remaining area kept untouched */ … … 981 1109 return ret; 982 1110 } 983 #else984 static inline void fill_remaining_elem_value(struct snd_ctl_elem_value *control,985 struct snd_ctl_elem_info *info,986 u32 pattern)987 {988 }989 990 static inline int sanity_check_elem_value(struct snd_card *card,991 struct snd_ctl_elem_value *control,992 struct snd_ctl_elem_info *info,993 u32 pattern)994 {995 return 0;996 }997 #endif998 1111 999 1112 static int __snd_ctl_elem_info(struct snd_card *card, … … 1091 1204 snd_ctl_build_ioff(&control->id, kctl, index_offset); 1092 1205 1093 #ifdef CONFIG_SND_CTL_ VALIDATION1206 #ifdef CONFIG_SND_CTL_DEBUG 1094 1207 /* info is needed only for validation */ 1095 1208 memset(&info, 0, sizeof(info)); … … 1168 1281 snd_ctl_build_ioff(&control->id, kctl, index_offset); 1169 1282 result = snd_power_ref_and_wait(card); 1283 /* validate input values */ 1284 #ifndef TARGET_OS2 1285 if ((IS_ENABLED(CONFIG_SND_CTL_INPUT_VALIDATION) || defined(CONFIG_SND_CTL_INPUT_VALIDATION)) && !result) { 1286 #else 1287 if (!result) { 1288 #endif 1289 struct snd_ctl_elem_info info; 1290 1291 memset(&info, 0, sizeof(info)); 1292 info.id = control->id; 1293 result = __snd_ctl_elem_info(card, kctl, &info, NULL); 1294 if (!result) 1295 result = sanity_check_input_values(card, control, &info, 1296 false); 1297 } 1170 1298 if (!result) 1171 1299 result = kctl->put(kctl, control); … … 1944 2072 * 1945 2073 * called from each device manager like pcm.c, hwdep.c, etc. 2074 * 2075 * Return: zero if successful, or a negative error code 1946 2076 */ 1947 2077 int snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn) … … 1956 2086 * control-ioctls 1957 2087 * @fcn: ioctl callback function 2088 * 2089 * Return: zero if successful, or a negative error code 1958 2090 */ 1959 2091 int snd_ctl_register_ioctl_compat(snd_kctl_ioctl_func_t fcn) … … 1991 2123 * snd_ctl_unregister_ioctl - de-register the device-specific control-ioctls 1992 2124 * @fcn: ioctl callback function to unregister 2125 * 2126 * Return: zero if successful, or a negative error code 1993 2127 */ 1994 2128 int snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn) … … 2003 2137 * 32bit control-ioctls 2004 2138 * @fcn: ioctl callback function to unregister 2139 * 2140 * Return: zero if successful, or a negative error code 2005 2141 */ 2006 2142 int snd_ctl_unregister_ioctl_compat(snd_kctl_ioctl_func_t fcn) … … 2058 2194 * @module_name: Name of the kernel module (NULL == build-in) 2059 2195 * 2060 * Return an error code when the module cannot be loaded.2196 * Return: zero if successful, or an error code when the module cannot be loaded 2061 2197 */ 2062 2198 int snd_ctl_request_layer(const char *module_name) … … 2209 2345 while (!list_empty(&card->controls)) { 2210 2346 control = snd_kcontrol(card->controls.next); 2211 snd_ctl_remove(card, control); 2212 } 2347 __snd_ctl_remove(card, control, false); 2348 } 2349 2350 #ifdef CONFIG_SND_CTL_FAST_LOOKUP 2351 xa_destroy(&card->ctl_numids); 2352 xa_destroy(&card->ctl_hash); 2353 #endif 2213 2354 up_write(&card->controls_rwsem); 2214 2355 put_device(&card->ctl_dev); … … 2255 2396 * This is a function that can be used as info callback for a standard 2256 2397 * boolean control with a single mono channel. 2398 * 2399 * Return: Zero (always successful) 2257 2400 */ 2258 2401 int snd_ctl_boolean_mono_info(struct snd_kcontrol *kcontrol, … … 2275 2418 * This is a function that can be used as info callback for a standard 2276 2419 * boolean control with stereo two channels. 2420 * 2421 * Return: Zero (always successful) 2277 2422 */ 2278 2423 int snd_ctl_boolean_stereo_info(struct snd_kcontrol *kcontrol, … … 2298 2443 * the caller has to fill @info->access. 2299 2444 * 2300 * Return: Zero .2445 * Return: Zero (always successful) 2301 2446 */ 2302 2447 int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels, -
GPL/branches/uniaud32-exp/alsa-kernel/core/device.c
r629 r750 248 248 * @SNDRV_DEV_DISCONNECTED is returned. 249 249 * Or for a non-existing device, -1 is returned as an error. 250 * 251 * Return: the current state, or -1 if not found 250 252 */ 251 253 int snd_device_get_state(struct snd_card *card, void *device_data) -
GPL/branches/uniaud32-exp/alsa-kernel/core/info.c
r739 r750 873 873 * This proc file entry will be registered via snd_card_register() call, and 874 874 * it will be removed automatically at the card removal, too. 875 * 876 * Return: zero if successful, or a negative error code 875 877 */ 876 878 int snd_card_rw_proc_new(struct snd_card *card, const char *name, -
GPL/branches/uniaud32-exp/alsa-kernel/core/init.c
r749 r750 218 218 * devres call orders. You can use snd_card_free_on_error() helper for 219 219 * handling it more easily. 220 * 221 * Return: zero if successful, or a negative error code 220 222 */ 221 223 int snd_devm_card_new(struct device *parent, int idx, const char *xid, … … 252 254 * the probe callback. It's just a small helper for simplifying the error 253 255 * handling with the managed devices. 256 * 257 * Return: zero if successful, or a negative error code 254 258 */ 255 259 int snd_card_free_on_error(struct device *dev, int ret) … … 315 319 INIT_LIST_HEAD(&card->controls); 316 320 INIT_LIST_HEAD(&card->ctl_files); 321 #ifdef CONFIG_SND_CTL_FAST_LOOKUP 322 xa_init(&card->ctl_numids); 323 xa_init(&card->ctl_hash); 324 #endif 317 325 spin_lock_init(&card->files_lock); 318 326 INIT_LIST_HEAD(&card->files_list); … … 371 379 * Returns a card object corresponding to the given index or NULL if not found. 372 380 * Release the object via snd_card_unref(). 381 * 382 * Return: a card object or NULL 373 383 */ 374 384 struct snd_card *snd_card_ref(int idx) … … 612 622 * is still in use, the function returns before freeing the resources. 613 623 * The card resources will be freed when the refcount gets to zero. 624 * 625 * Return: zero if successful, or a negative error code 614 626 */ 615 627 int snd_card_free_when_closed(struct snd_card *card) … … 781 793 { 782 794 struct snd_card *card = container_of(dev, struct snd_card, card_dev); 783 return s cnprintf(buf, PAGE_SIZE, "%s\n", card->id);795 return sysfs_emit(buf, "%s\n", card->id); 784 796 } 785 797 … … 819 831 { 820 832 struct snd_card *card = container_of(dev, struct snd_card, card_dev); 821 return s cnprintf(buf, PAGE_SIZE, "%i\n", card->number);833 return sysfs_emit(buf, "%i\n", card->number); 822 834 } 823 835 … … 839 851 * @card: card instance 840 852 * @group: attribute group to append 853 * 854 * Return: zero if successful, or a negative error code 841 855 */ 842 856 int snd_card_add_dev_attr(struct snd_card *card, -
GPL/branches/uniaud32-exp/alsa-kernel/core/memalloc.c
r737 r750 366 366 * SNDRV_DMA_TYPE_VMALLOC type. 367 367 * 368 * The function returns the snd_dma_buffer object at success, or NULL if failed.368 * Return: the snd_dma_buffer object at success, or NULL if failed 369 369 */ 370 370 struct snd_dma_buffer * -
GPL/branches/uniaud32-exp/alsa-kernel/core/pcm.c
r739 r750 220 220 * snd_pcm_format_name - Return a name string for the given PCM format 221 221 * @format: PCM format 222 * 223 * Return: the format name string 222 224 */ 223 225 const char *snd_pcm_format_name(snd_pcm_format_t format) … … 1038 1040 else 1039 1041 str = strs[pcm->dev_class]; 1040 return s printf(buf, "%s\n", str);1042 return sysfs_emit(buf, "%s\n", str); 1041 1043 } 1042 1044 … … 1149 1151 * called for each registered PCM devices. This exists only for PCM OSS 1150 1152 * emulation, so far. 1153 * 1154 * Return: zero if successful, or a negative error code 1151 1155 */ 1152 1156 int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) -
GPL/branches/uniaud32-exp/alsa-kernel/core/pcm_memory.c
r737 r750 359 359 * 360 360 * Upon successful buffer allocation and setup, the function returns 0. 361 * 362 * Return: zero if successful, or a negative error code 361 363 */ 362 364 int snd_pcm_set_managed_buffer(struct snd_pcm_substream *substream, int type, … … 378 380 * Do pre-allocation to all substreams of the given pcm for the specified DMA 379 381 * type and size, and set the managed_buffer_alloc flag to each substream. 382 * 383 * Return: zero if successful, or a negative error code 380 384 */ 381 385 int snd_pcm_set_managed_buffer_all(struct snd_pcm *pcm, int type, -
GPL/branches/uniaud32-exp/alsa-kernel/core/pcm_native.c
r739 r750 3467 3467 * and it allows only the limited set of ioctls (hw_params, sw_params, 3468 3468 * prepare, start, drain, drop, forward). 3469 * 3470 * Return: zero if successful, or a negative error code 3469 3471 */ 3470 3472 int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, … … 3871 3873 * This is the default mmap handler for PCM data. When mmap pcm_ops is NULL, 3872 3874 * this function is invoked implicitly. 3875 * 3876 * Return: zero if successful, or a negative error code 3873 3877 */ 3874 3878 int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream, … … 3897 3901 * wants to mmap it, pass this function as mmap pcm_ops. Note that this 3898 3902 * is supposed to work only on limited architectures. 3903 * 3904 * Return: zero if successful, or a negative error code 3899 3905 */ 3900 3906 int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, -
GPL/branches/uniaud32-exp/alsa-kernel/core/rawmidi.c
r711 r750 116 116 static bool snd_rawmidi_ready(struct snd_rawmidi_substream *substream) 117 117 { 118 struct snd_rawmidi_runtime *runtime = substream->runtime;119 118 unsigned long flags; 120 119 bool ready; 121 120 122 spin_lock_irqsave(& runtime->lock, flags);123 ready = __snd_rawmidi_ready( runtime);124 spin_unlock_irqrestore(& runtime->lock, flags);121 spin_lock_irqsave(&substream->lock, flags); 122 ready = __snd_rawmidi_ready(substream->runtime); 123 spin_unlock_irqrestore(&substream->lock, flags); 125 124 return ready; 126 125 } … … 144 143 } 145 144 146 /* buffer refcount management: call with runtime->lock held */145 /* buffer refcount management: call with substream->lock held */ 147 146 static inline void snd_rawmidi_buffer_ref(struct snd_rawmidi_runtime *runtime) 148 147 { … … 153 152 { 154 153 runtime->buffer_ref--; 154 } 155 156 static void snd_rawmidi_buffer_ref_sync(struct snd_rawmidi_substream *substream) 157 { 158 int loop = HZ; 159 160 spin_lock_irq(&substream->lock); 161 while (substream->runtime->buffer_ref) { 162 spin_unlock_irq(&substream->lock); 163 if (!--loop) { 164 rmidi_err(substream->rmidi, "Buffer ref sync timeout\n"); 165 return; 166 } 167 schedule_timeout_uninterruptible(1); 168 spin_lock_irq(&substream->lock); 169 } 170 spin_unlock_irq(&substream->lock); 155 171 } 156 172 … … 163 179 return -ENOMEM; 164 180 runtime->substream = substream; 165 spin_lock_init(&runtime->lock);166 181 init_waitqueue_head(&runtime->sleep); 167 182 INIT_WORK(&runtime->event_work, snd_rawmidi_input_event_work); … … 217 232 } 218 233 219 static void reset_runtime_ptrs(struct snd_rawmidi_ runtime *runtime,234 static void reset_runtime_ptrs(struct snd_rawmidi_substream *substream, 220 235 bool is_input) 221 236 { 222 237 unsigned long flags; 223 238 224 spin_lock_irqsave(&runtime->lock, flags); 225 __reset_runtime_ptrs(runtime, is_input); 226 spin_unlock_irqrestore(&runtime->lock, flags); 239 spin_lock_irqsave(&substream->lock, flags); 240 if (substream->opened && substream->runtime) 241 __reset_runtime_ptrs(substream->runtime, is_input); 242 spin_unlock_irqrestore(&substream->lock, flags); 227 243 } 228 244 … … 230 246 { 231 247 snd_rawmidi_output_trigger(substream, 0); 232 reset_runtime_ptrs(substream ->runtime, false);248 reset_runtime_ptrs(substream, false); 233 249 return 0; 234 250 } … … 237 253 int snd_rawmidi_drain_output(struct snd_rawmidi_substream *substream) 238 254 { 239 int err ;255 int err = 0; 240 256 long timeout; 241 struct snd_rawmidi_runtime *runtime = substream->runtime; 242 243 err = 0; 244 runtime->drain = 1; 257 struct snd_rawmidi_runtime *runtime; 258 259 spin_lock_irq(&substream->lock); 260 runtime = substream->runtime; 261 if (!substream->opened || !runtime || !runtime->buffer) { 262 err = -EINVAL; 263 } else { 264 snd_rawmidi_buffer_ref(runtime); 265 runtime->drain = 1; 266 } 267 spin_unlock_irq(&substream->lock); 268 if (err < 0) 269 return err; 270 245 271 #ifndef TARGET_OS2 246 272 timeout = wait_event_interruptible_timeout(runtime->sleep, … … 250 276 timeout = interruptible_sleep_on_timeout(&runtime->sleep, 10 * HZ); 251 277 #endif 278 279 spin_lock_irq(&substream->lock); 252 280 if (signal_pending(current)) 253 281 err = -ERESTARTSYS; … … 259 287 } 260 288 runtime->drain = 0; 289 spin_unlock_irq(&substream->lock); 290 261 291 if (err != -ERESTARTSYS) { 262 292 /* we need wait a while to make sure that Tx FIFOs are empty */ … … 267 297 snd_rawmidi_drop_output(substream); 268 298 } 299 300 spin_lock_irq(&substream->lock); 301 snd_rawmidi_buffer_unref(runtime); 302 spin_unlock_irq(&substream->lock); 303 269 304 return err; 270 305 } … … 274 309 { 275 310 snd_rawmidi_input_trigger(substream, 0); 276 reset_runtime_ptrs(substream ->runtime, true);311 reset_runtime_ptrs(substream, true); 277 312 return 0; 278 313 } … … 329 364 return err; 330 365 } 366 spin_lock_irq(&substream->lock); 331 367 substream->opened = 1; 332 368 substream->active_sensing = 0; … … 335 371 substream->pid = get_pid(task_pid(current)); 336 372 rmidi->streams[substream->stream].substream_opened++; 373 spin_unlock_irq(&substream->lock); 337 374 } 338 375 substream->use_count++; … … 539 576 snd_rawmidi_output_trigger(substream, 0); 540 577 } 541 } 578 snd_rawmidi_buffer_ref_sync(substream); 579 } 580 spin_lock_irq(&substream->lock); 581 substream->opened = 0; 582 substream->append = 0; 583 spin_unlock_irq(&substream->lock); 542 584 substream->ops->close(substream); 543 585 if (substream->runtime->private_free) 544 586 substream->runtime->private_free(substream); 545 587 snd_rawmidi_runtime_free(substream); 546 substream->opened = 0;547 substream->append = 0;548 588 put_pid(substream->pid); 549 589 substream->pid = NULL; … … 696 736 } 697 737 698 static int resize_runtime_buffer(struct snd_rawmidi_ runtime *runtime,738 static int resize_runtime_buffer(struct snd_rawmidi_substream *substream, 699 739 struct snd_rawmidi_params *params, 700 740 bool is_input) 701 741 { 742 struct snd_rawmidi_runtime *runtime = substream->runtime; 702 743 char *newbuf, *oldbuf; 703 744 unsigned int framing = params->mode & SNDRV_RAWMIDI_MODE_FRAMING_MASK; … … 713 754 if (!newbuf) 714 755 return -ENOMEM; 715 spin_lock_irq(& runtime->lock);756 spin_lock_irq(&substream->lock); 716 757 if (runtime->buffer_ref) { 717 spin_unlock_irq(& runtime->lock);758 spin_unlock_irq(&substream->lock); 718 759 kvfree(newbuf); 719 760 return -EBUSY; … … 723 764 runtime->buffer_size = params->buffer_size; 724 765 __reset_runtime_ptrs(runtime, is_input); 725 spin_unlock_irq(& runtime->lock);766 spin_unlock_irq(&substream->lock); 726 767 kvfree(oldbuf); 727 768 } … … 733 774 struct snd_rawmidi_params *params) 734 775 { 776 int err; 777 778 snd_rawmidi_drain_output(substream); 779 mutex_lock(&substream->rmidi->open_mutex); 735 780 if (substream->append && substream->use_count > 1) 736 return -EBUSY; 737 snd_rawmidi_drain_output(substream); 738 substream->active_sensing = !params->no_active_sensing; 739 return resize_runtime_buffer(substream->runtime, params, false); 781 err = -EBUSY; 782 else 783 err = resize_runtime_buffer(substream, params, false); 784 785 if (!err) 786 substream->active_sensing = !params->no_active_sensing; 787 mutex_unlock(&substream->rmidi->open_mutex); 788 return err; 740 789 } 741 790 EXPORT_SYMBOL(snd_rawmidi_output_params); … … 748 797 int err; 749 798 799 snd_rawmidi_drain_input(substream); 800 mutex_lock(&substream->rmidi->open_mutex); 750 801 if (framing == SNDRV_RAWMIDI_MODE_FRAMING_NONE && clock_type != SNDRV_RAWMIDI_MODE_CLOCK_NONE) 751 return-EINVAL;802 err = -EINVAL; 752 803 else if (clock_type > SNDRV_RAWMIDI_MODE_CLOCK_MONOTONIC_RAW) 753 return -EINVAL; 754 if (framing > SNDRV_RAWMIDI_MODE_FRAMING_TSTAMP) 755 return -EINVAL; 756 snd_rawmidi_drain_input(substream); 757 err = resize_runtime_buffer(substream->runtime, params, true); 758 if (err < 0) 759 return err; 760 761 substream->framing = framing; 762 substream->clock_type = clock_type; 804 err = -EINVAL; 805 else if (framing > SNDRV_RAWMIDI_MODE_FRAMING_TSTAMP) 806 err = -EINVAL; 807 else 808 err = resize_runtime_buffer(substream, params, true); 809 810 if (!err) { 811 substream->framing = framing; 812 substream->clock_type = clock_type; 813 } 814 mutex_unlock(&substream->rmidi->open_mutex); 763 815 return 0; 764 816 } … … 773 825 memset(status, 0, sizeof(*status)); 774 826 status->stream = SNDRV_RAWMIDI_STREAM_OUTPUT; 775 spin_lock_irq(& runtime->lock);827 spin_lock_irq(&substream->lock); 776 828 status->avail = runtime->avail; 777 spin_unlock_irq(& runtime->lock);829 spin_unlock_irq(&substream->lock); 778 830 return 0; 779 831 } … … 786 838 memset(status, 0, sizeof(*status)); 787 839 status->stream = SNDRV_RAWMIDI_STREAM_INPUT; 788 spin_lock_irq(& runtime->lock);840 spin_lock_irq(&substream->lock); 789 841 status->avail = runtime->avail; 790 842 status->xruns = runtime->xruns; 791 843 runtime->xruns = 0; 792 spin_unlock_irq(& runtime->lock);844 spin_unlock_irq(&substream->lock); 793 845 return 0; 794 846 } … … 1092 1144 struct timespec64 ts64 = get_framing_tstamp(substream); 1093 1145 int result = 0, count1; 1094 struct snd_rawmidi_runtime *runtime = substream->runtime; 1095 1096 if (!substream->opened) 1097 return -EBADFD; 1098 if (runtime->buffer == NULL) { 1146 struct snd_rawmidi_runtime *runtime; 1147 1148 spin_lock_irqsave(&substream->lock, flags); 1149 if (!substream->opened) { 1150 result = -EBADFD; 1151 goto unlock; 1152 } 1153 runtime = substream->runtime; 1154 if (!runtime || !runtime->buffer) { 1099 1155 rmidi_dbg(substream->rmidi, 1100 1156 "snd_rawmidi_receive: input is not active!!!\n"); 1101 re turn-EINVAL;1102 }1103 1104 spin_lock_irqsave(&runtime->lock, flags); 1157 result = -EINVAL; 1158 goto unlock; 1159 } 1160 1105 1161 if (substream->framing == SNDRV_RAWMIDI_MODE_FRAMING_TSTAMP) { 1106 1162 result = receive_with_tstamp_framing(substream, buffer, count, &ts64); … … 1149 1205 wake_up(&runtime->sleep); 1150 1206 } 1151 spin_unlock_irqrestore(&runtime->lock, flags); 1207 unlock: 1208 spin_unlock_irqrestore(&substream->lock, flags); 1152 1209 return result; 1153 1210 } … … 1164 1221 int err = 0; 1165 1222 1166 spin_lock_irqsave(& runtime->lock, flags);1223 spin_lock_irqsave(&substream->lock, flags); 1167 1224 snd_rawmidi_buffer_ref(runtime); 1168 1225 while (count > 0 && runtime->avail) { … … 1182 1239 memcpy(kernelbuf + result, runtime->buffer + appl_ptr, count1); 1183 1240 if (userbuf) { 1184 spin_unlock_irqrestore(& runtime->lock, flags);1241 spin_unlock_irqrestore(&substream->lock, flags); 1185 1242 if (copy_to_user(userbuf + result, 1186 1243 runtime->buffer + appl_ptr, count1)) 1187 1244 err = -EFAULT; 1188 spin_lock_irqsave(& runtime->lock, flags);1245 spin_lock_irqsave(&substream->lock, flags); 1189 1246 if (err) 1190 1247 goto out; … … 1195 1252 out: 1196 1253 snd_rawmidi_buffer_unref(runtime); 1197 spin_unlock_irqrestore(& runtime->lock, flags);1254 spin_unlock_irqrestore(&substream->lock, flags); 1198 1255 return result > 0 ? result : err; 1199 1256 } … … 1224 1281 result = 0; 1225 1282 while (count > 0) { 1226 spin_lock_irq(& runtime->lock);1283 spin_lock_irq(&substream->lock); 1227 1284 while (!__snd_rawmidi_ready(runtime)) { 1228 1285 wait_queue_entry_t wait; 1229 1286 1230 1287 if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) { 1231 spin_unlock_irq(& runtime->lock);1288 spin_unlock_irq(&substream->lock); 1232 1289 return result > 0 ? result : -EAGAIN; 1233 1290 } … … 1235 1292 add_wait_queue(&runtime->sleep, &wait); 1236 1293 set_current_state(TASK_INTERRUPTIBLE); 1237 spin_unlock_irq(& runtime->lock);1294 spin_unlock_irq(&substream->lock); 1238 1295 schedule(); 1239 1296 remove_wait_queue(&runtime->sleep, &wait); … … 1242 1299 if (signal_pending(current)) 1243 1300 return result > 0 ? result : -ERESTARTSYS; 1244 spin_lock_irq(& runtime->lock);1301 spin_lock_irq(&substream->lock); 1245 1302 if (!runtime->avail) { 1246 spin_unlock_irq(& runtime->lock);1303 spin_unlock_irq(&substream->lock); 1247 1304 return result > 0 ? result : -EIO; 1248 1305 } 1249 1306 } 1250 spin_unlock_irq(& runtime->lock);1307 spin_unlock_irq(&substream->lock); 1251 1308 count1 = snd_rawmidi_kernel_read1(substream, 1252 1309 (unsigned char __user *)buf, … … 1270 1327 int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream) 1271 1328 { 1272 struct snd_rawmidi_runtime *runtime = substream->runtime;1329 struct snd_rawmidi_runtime *runtime; 1273 1330 int result; 1274 1331 unsigned long flags; 1275 1332 1276 if (runtime->buffer == NULL) { 1333 spin_lock_irqsave(&substream->lock, flags); 1334 runtime = substream->runtime; 1335 if (!substream->opened || !runtime || !runtime->buffer) { 1277 1336 rmidi_dbg(substream->rmidi, 1278 1337 "snd_rawmidi_transmit_empty: output is not active!!!\n"); 1279 re turn1;1280 } 1281 spin_lock_irqsave(&runtime->lock, flags);1282 result = runtime->avail >= runtime->buffer_size;1283 spin_unlock_irqrestore(& runtime->lock, flags);1338 result = 1; 1339 } else { 1340 result = runtime->avail >= runtime->buffer_size; 1341 } 1342 spin_unlock_irqrestore(&substream->lock, flags); 1284 1343 return result; 1285 1344 } 1286 1345 EXPORT_SYMBOL(snd_rawmidi_transmit_empty); 1287 1346 1288 /* *1347 /* 1289 1348 * __snd_rawmidi_transmit_peek - copy data from the internal buffer 1290 1349 * @substream: the rawmidi substream … … 1294 1353 * This is a variant of snd_rawmidi_transmit_peek() without spinlock. 1295 1354 */ 1296 int __snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream,1297 unsigned char *buffer, int count)1355 static int __snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream, 1356 unsigned char *buffer, int count) 1298 1357 { 1299 1358 int result, count1; … … 1332 1391 return result; 1333 1392 } 1334 EXPORT_SYMBOL(__snd_rawmidi_transmit_peek);1335 1393 1336 1394 /** … … 1351 1409 unsigned char *buffer, int count) 1352 1410 { 1353 struct snd_rawmidi_runtime *runtime = substream->runtime;1354 1411 int result; 1355 1412 unsigned long flags; 1356 1413 1357 spin_lock_irqsave(&runtime->lock, flags); 1358 result = __snd_rawmidi_transmit_peek(substream, buffer, count); 1359 spin_unlock_irqrestore(&runtime->lock, flags); 1414 spin_lock_irqsave(&substream->lock, flags); 1415 if (!substream->opened || !substream->runtime) 1416 result = -EBADFD; 1417 else 1418 result = __snd_rawmidi_transmit_peek(substream, buffer, count); 1419 spin_unlock_irqrestore(&substream->lock, flags); 1360 1420 return result; 1361 1421 } 1362 1422 EXPORT_SYMBOL(snd_rawmidi_transmit_peek); 1363 1423 1364 /* *1424 /* 1365 1425 * __snd_rawmidi_transmit_ack - acknowledge the transmission 1366 1426 * @substream: the rawmidi substream … … 1369 1429 * This is a variant of __snd_rawmidi_transmit_ack() without spinlock. 1370 1430 */ 1371 int __snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count) 1431 static int __snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, 1432 int count) 1372 1433 { 1373 1434 struct snd_rawmidi_runtime *runtime = substream->runtime; … … 1389 1450 return count; 1390 1451 } 1391 EXPORT_SYMBOL(__snd_rawmidi_transmit_ack);1392 1452 1393 1453 /** … … 1404 1464 int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count) 1405 1465 { 1406 struct snd_rawmidi_runtime *runtime = substream->runtime;1407 1466 int result; 1408 1467 unsigned long flags; 1409 1468 1410 spin_lock_irqsave(&runtime->lock, flags); 1411 result = __snd_rawmidi_transmit_ack(substream, count); 1412 spin_unlock_irqrestore(&runtime->lock, flags); 1469 spin_lock_irqsave(&substream->lock, flags); 1470 if (!substream->opened || !substream->runtime) 1471 result = -EBADFD; 1472 else 1473 result = __snd_rawmidi_transmit_ack(substream, count); 1474 spin_unlock_irqrestore(&substream->lock, flags); 1413 1475 return result; 1414 1476 } … … 1428 1490 unsigned char *buffer, int count) 1429 1491 { 1430 struct snd_rawmidi_runtime *runtime = substream->runtime;1431 1492 int result; 1432 1493 unsigned long flags; 1433 1494 1434 spin_lock_irqsave(& runtime->lock, flags);1495 spin_lock_irqsave(&substream->lock, flags); 1435 1496 if (!substream->opened) 1436 1497 result = -EBADFD; … … 1442 1503 result = __snd_rawmidi_transmit_ack(substream, count); 1443 1504 } 1444 spin_unlock_irqrestore(& runtime->lock, flags);1505 spin_unlock_irqrestore(&substream->lock, flags); 1445 1506 return result; 1446 1507 } … … 1455 1516 int snd_rawmidi_proceed(struct snd_rawmidi_substream *substream) 1456 1517 { 1457 struct snd_rawmidi_runtime *runtime = substream->runtime;1518 struct snd_rawmidi_runtime *runtime; 1458 1519 unsigned long flags; 1459 1520 int count = 0; 1460 1521 1461 spin_lock_irqsave(&runtime->lock, flags); 1462 if (runtime->avail < runtime->buffer_size) { 1522 spin_lock_irqsave(&substream->lock, flags); 1523 runtime = substream->runtime; 1524 if (substream->opened && runtime && 1525 runtime->avail < runtime->buffer_size) { 1463 1526 count = runtime->buffer_size - runtime->avail; 1464 1527 __snd_rawmidi_transmit_ack(substream, count); 1465 1528 } 1466 spin_unlock_irqrestore(& runtime->lock, flags);1529 spin_unlock_irqrestore(&substream->lock, flags); 1467 1530 return count; 1468 1531 } … … 1485 1548 1486 1549 result = 0; 1487 spin_lock_irqsave(& runtime->lock, flags);1550 spin_lock_irqsave(&substream->lock, flags); 1488 1551 if (substream->append) { 1489 1552 if ((long)runtime->avail < count) { 1490 spin_unlock_irqrestore(& runtime->lock, flags);1553 spin_unlock_irqrestore(&substream->lock, flags); 1491 1554 return -EAGAIN; 1492 1555 } … … 1510 1573 kernelbuf + result, count1); 1511 1574 else if (userbuf) { 1512 spin_unlock_irqrestore(& runtime->lock, flags);1575 spin_unlock_irqrestore(&substream->lock, flags); 1513 1576 if (copy_from_user(runtime->buffer + appl_ptr, 1514 1577 userbuf + result, count1)) { 1515 spin_lock_irqsave(& runtime->lock, flags);1578 spin_lock_irqsave(&substream->lock, flags); 1516 1579 result = result > 0 ? result : -EFAULT; 1517 1580 goto __end; 1518 1581 } 1519 spin_lock_irqsave(& runtime->lock, flags);1582 spin_lock_irqsave(&substream->lock, flags); 1520 1583 } 1521 1584 result += count1; … … 1525 1588 count1 = runtime->avail < runtime->buffer_size; 1526 1589 snd_rawmidi_buffer_unref(runtime); 1527 spin_unlock_irqrestore(& runtime->lock, flags);1590 spin_unlock_irqrestore(&substream->lock, flags); 1528 1591 if (count1) 1529 1592 snd_rawmidi_output_trigger(substream, 1); … … 1555 1618 result = 0; 1556 1619 while (count > 0) { 1557 spin_lock_irq(& runtime->lock);1620 spin_lock_irq(&substream->lock); 1558 1621 while (!snd_rawmidi_ready_append(substream, count)) { 1559 1622 wait_queue_entry_t wait; 1560 1623 1561 1624 if (file->f_flags & O_NONBLOCK) { 1562 spin_unlock_irq(& runtime->lock);1625 spin_unlock_irq(&substream->lock); 1563 1626 return result > 0 ? result : -EAGAIN; 1564 1627 } … … 1566 1629 add_wait_queue(&runtime->sleep, &wait); 1567 1630 set_current_state(TASK_INTERRUPTIBLE); 1568 spin_unlock_irq(& runtime->lock);1631 spin_unlock_irq(&substream->lock); 1569 1632 timeout = schedule_timeout(30 * HZ); 1570 1633 remove_wait_queue(&runtime->sleep, &wait); … … 1573 1636 if (signal_pending(current)) 1574 1637 return result > 0 ? result : -ERESTARTSYS; 1575 spin_lock_irq(& runtime->lock);1638 spin_lock_irq(&substream->lock); 1576 1639 if (!runtime->avail && !timeout) { 1577 spin_unlock_irq(& runtime->lock);1640 spin_unlock_irq(&substream->lock); 1578 1641 return result > 0 ? result : -EIO; 1579 1642 } 1580 1643 } 1581 spin_unlock_irq(& runtime->lock);1644 spin_unlock_irq(&substream->lock); 1582 1645 count1 = snd_rawmidi_kernel_write1(substream, buf, NULL, count); 1583 1646 if (count1 < 0) … … 1590 1653 } 1591 1654 if (file->f_flags & O_DSYNC) { 1592 spin_lock_irq(& runtime->lock);1655 spin_lock_irq(&substream->lock); 1593 1656 while (runtime->avail != runtime->buffer_size) { 1594 1657 wait_queue_entry_t wait; … … 1598 1661 add_wait_queue(&runtime->sleep, &wait); 1599 1662 set_current_state(TASK_INTERRUPTIBLE); 1600 spin_unlock_irq(& runtime->lock);1663 spin_unlock_irq(&substream->lock); 1601 1664 timeout = schedule_timeout(30 * HZ); 1602 1665 remove_wait_queue(&runtime->sleep, &wait); … … 1605 1668 if (runtime->avail == last_avail && !timeout) 1606 1669 return result > 0 ? result : -EIO; 1607 spin_lock_irq(& runtime->lock);1608 } 1609 spin_unlock_irq(& runtime->lock);1670 spin_lock_irq(&substream->lock); 1671 } 1672 spin_unlock_irq(&substream->lock); 1610 1673 } 1611 1674 return result; … … 1678 1741 pid_vnr(substream->pid)); 1679 1742 runtime = substream->runtime; 1680 spin_lock_irq(& runtime->lock);1743 spin_lock_irq(&substream->lock); 1681 1744 buffer_size = runtime->buffer_size; 1682 1745 avail = runtime->avail; 1683 spin_unlock_irq(& runtime->lock);1746 spin_unlock_irq(&substream->lock); 1684 1747 snd_iprintf(buffer, 1685 1748 " Mode : %s\n" … … 1705 1768 pid_vnr(substream->pid)); 1706 1769 runtime = substream->runtime; 1707 spin_lock_irq(& runtime->lock);1770 spin_lock_irq(&substream->lock); 1708 1771 buffer_size = runtime->buffer_size; 1709 1772 avail = runtime->avail; 1710 1773 xruns = runtime->xruns; 1711 spin_unlock_irq(& runtime->lock);1774 spin_unlock_irq(&substream->lock); 1712 1775 snd_iprintf(buffer, 1713 1776 " Buffer size : %lu\n" … … 1763 1826 substream->rmidi = rmidi; 1764 1827 substream->pstr = stream; 1828 spin_lock_init(&substream->lock); 1765 1829 list_add_tail(&substream->list, &stream->substreams); 1766 1830 stream->substream_count++; -
GPL/branches/uniaud32-exp/alsa-kernel/core/vmaster.c
r629 r750 500 500 * 501 501 * Apply the function @func to each follower kctl of the given vmaster kctl. 502 * Returns 0 if successful, or a negative error code. 502 * 503 * Return: 0 if successful, or a negative error code 503 504 */ 504 505 int snd_ctl_apply_vmaster_followers(struct snd_kcontrol *kctl, -
GPL/branches/uniaud32-exp/alsa-kernel/hda/ext/hdac_ext_controller.c
r738 r750 14 14 #include <sound/hda_register.h> 15 15 #include <sound/hdaudio_ext.h> 16 17 /*18 * maximum HDAC capablities we should parse to avoid endless looping:19 * currently we have 4 extended caps, so this is future proof for now.20 * extend when this limit is seen meeting in real HW21 */22 #define HDAC_MAX_CAPS 1023 16 24 17 /* -
GPL/branches/uniaud32-exp/alsa-kernel/hda/hdac_bus.c
r693 r750 194 194 continue; 195 195 codec = bus->caddr_tbl[caddr & 0x0f]; 196 if (!codec || !codec-> dev.driver)196 if (!codec || !codec->registered) 197 197 continue; 198 198 spin_unlock_irq(&bus->reg_lock); -
GPL/branches/uniaud32-exp/alsa-kernel/hda/hdac_controller.c
r710 r750 481 481 snd_hdac_stream_updateb(azx_dev, SD_CTL, SD_INT_MASK, 0); 482 482 483 /* disable SIE for all streams */ 484 snd_hdac_chip_writeb(bus, INTCTL, 0); 485 486 /* disable controller CIE and GIE */ 487 snd_hdac_chip_updatel(bus, INTCTL, AZX_INT_CTRL_EN | AZX_INT_GLOBAL_EN, 0); 483 /* disable SIE for all streams & disable controller CIE and GIE */ 484 snd_hdac_chip_writel(bus, INTCTL, 0); 488 485 } 489 486 -
GPL/branches/uniaud32-exp/alsa-kernel/hda/trace.h
r615 r750 20 20 TP_PROTO(struct hdac_bus *bus, unsigned int cmd), 21 21 TP_ARGS(bus, cmd), 22 TP_STRUCT__entry(__dynamic_array(char, msg, HDAC_MSG_MAX)), 22 TP_STRUCT__entry( 23 __string(name, dev_name((bus)->dev)) 24 __field(u32, cmd) 25 ), 23 26 TP_fast_assign( 24 snprintf(__get_str(msg), HDAC_MSG_MAX, 25 "[%s:%d] val=0x%08x", 26 dev_name((bus)->dev), (cmd) >> 28, cmd); 27 __assign_str(name, dev_name((bus)->dev)); 28 __entry->cmd = cmd; 27 29 ), 28 TP_printk(" %s", __get_str(msg))30 TP_printk("[%s:%d] val=0x%08x", __get_str(name), __entry->cmd >> 28, __entry->cmd) 29 31 ); 30 32 … … 32 34 TP_PROTO(struct hdac_bus *bus, unsigned int addr, unsigned int res), 33 35 TP_ARGS(bus, addr, res), 34 TP_STRUCT__entry(__dynamic_array(char, msg, HDAC_MSG_MAX)), 36 TP_STRUCT__entry( 37 __string(name, dev_name((bus)->dev)) 38 __field(u32, addr) 39 __field(u32, res) 40 ), 35 41 TP_fast_assign( 36 snprintf(__get_str(msg), HDAC_MSG_MAX,37 "[%s:%d] val=0x%08x",38 dev_name((bus)->dev), addr, res);42 __assign_str(name, dev_name((bus)->dev)); 43 __entry->addr = addr; 44 __entry->res = res; 39 45 ), 40 TP_printk(" %s", __get_str(msg))46 TP_printk("[%s:%d] val=0x%08x", __get_str(name), __entry->addr, __entry->res) 41 47 ); 42 48 … … 44 50 TP_PROTO(struct hdac_bus *bus, u32 res, u32 res_ex), 45 51 TP_ARGS(bus, res, res_ex), 46 TP_STRUCT__entry(__dynamic_array(char, msg, HDAC_MSG_MAX)), 52 TP_STRUCT__entry( 53 __string(name, dev_name((bus)->dev)) 54 __field(u32, res) 55 __field(u32, res_ex) 56 ), 47 57 TP_fast_assign( 48 snprintf(__get_str(msg), HDAC_MSG_MAX,49 "[%s:%d] res=0x%08x, res_ex=0x%08x",50 dev_name((bus)->dev), res_ex & 0x0f, res, res_ex);58 __assign_str(name, dev_name((bus)->dev)); 59 __entry->res = res; 60 __entry->res_ex = res_ex; 51 61 ), 52 TP_printk("%s", __get_str(msg)) 62 TP_printk("[%s:%d] res=0x%08x, res_ex=0x%08x", __get_str(name), 63 __entry->res_ex & 0x0f, __entry->res, __entry->res_ex) 53 64 ); 54 65 -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/config.h
r737 r750 23 23 #define CONFIG_PM 24 24 #define CONFIG_PM_SLEEP 25 #define CONFIG_SND_CTL_INPUT_VALIDATION 0 25 26 #ifdef DEBUG 26 27 #define CONFIG_SND_DEBUG_DETECT -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/control.h
r739 r750 24 24 25 25 /* internal flag for skipping validations */ 26 #ifdef CONFIG_SND_CTL_ VALIDATION26 #ifdef CONFIG_SND_CTL_DEBUG 27 27 #define SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK (1 << 24) 28 28 #define snd_ctl_skip_validation(info) \ -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/core.h
r739 r750 18 18 #include <linux/stringify.h> 19 19 #include <linux/printk.h> 20 #include <linux/xarray.h> 20 21 21 22 /* number of supported soundcards */ … … 107 108 struct list_head controls; /* all controls for this card */ 108 109 struct list_head ctl_files; /* active control files */ 110 #ifdef CONFIG_SND_CTL_FAST_LOOKUP 111 struct xarray ctl_numids; /* hash table for numids */ 112 struct xarray ctl_hash; /* hash table for ctl id matching */ 113 bool ctl_hash_collision; /* ctl_hash collision seen? */ 114 #endif 109 115 110 116 struct snd_info_entry *proc_root; /* root for soundcard specific files */ -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/dmaengine_pcm.h
r737 r750 16 16 * substream 17 17 * @substream: PCM substream 18 * 19 * Return: DMA transfer direction 18 20 */ 19 21 static inline enum dma_transfer_direction -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/hda_codec.h
r739 r750 232 232 unsigned int configured:1; /* codec was configured */ 233 233 unsigned int in_freeing:1; /* being released */ 234 unsigned int registered:1; /* codec was registered */235 234 unsigned int display_power_control:1; /* needs display power */ 236 235 unsigned int spdif_status_reset :1; /* needs to toggle SPDIF for each -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/hdaudio.h
r738 r750 94 94 bool caps_overwriting:1; /* caps overwrite being in process */ 95 95 bool cache_coef:1; /* cache COEF read/write too */ 96 unsigned int registered:1; /* codec was registered */ 96 97 }; 97 98 -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/hdmi-codec.h
r697 r750 33 33 unsigned int bit_clk_inv:1; 34 34 unsigned int frame_clk_inv:1; 35 unsigned int bit_clk_ master:1;36 unsigned int frame_clk_ master:1;35 unsigned int bit_clk_provider:1; 36 unsigned int frame_clk_provider:1; 37 37 /* bit_fmt could be standard PCM format or 38 38 * IEC958 encoded format. ALSA IEC958 plugin will pass -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/madera-pdata.h
r615 r750 10 10 #define MADERA_CODEC_PDATA_H 11 11 12 #include <linux/ kernel.h>12 #include <linux/types.h> 13 13 14 14 #define MADERA_MAX_INPUT 6 -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/pcm.h
r739 r750 608 608 * @substream: substream to check 609 609 * 610 * Return s true if the given substream is being linked with others.610 * Return: true if the given substream is being linked with others 611 611 */ 612 612 static inline int snd_pcm_stream_linked(struct snd_pcm_substream *substream) … … 681 681 * @substream: substream to check 682 682 * 683 * Return strue if the given substream is in the state RUNNING, or in the683 * Return: true if the given substream is in the state RUNNING, or in the 684 684 * state DRAINING for playback. 685 685 */ … … 695 695 * @runtime: PCM runtime instance 696 696 * @size: size in bytes 697 * 698 * Return: the size in samples 697 699 */ 698 700 static inline ssize_t bytes_to_samples(struct snd_pcm_runtime *runtime, ssize_t size) … … 705 707 * @runtime: PCM runtime instance 706 708 * @size: size in bytes 709 * 710 * Return: the size in frames 707 711 */ 708 712 static inline snd_pcm_sframes_t bytes_to_frames(struct snd_pcm_runtime *runtime, ssize_t size) … … 715 719 * @runtime: PCM runtime instance 716 720 * @size: size in samples 721 * 722 * Return: the byte size 717 723 */ 718 724 static inline ssize_t samples_to_bytes(struct snd_pcm_runtime *runtime, ssize_t size) … … 725 731 * @runtime: PCM runtime instance 726 732 * @size: size in frames 733 * 734 * Return: the byte size 727 735 */ 728 736 static inline ssize_t frames_to_bytes(struct snd_pcm_runtime *runtime, snd_pcm_sframes_t size) … … 735 743 * @runtime: PCM runtime instance 736 744 * @bytes: size in bytes 745 * 746 * Return: true if aligned, or false if not 737 747 */ 738 748 static inline int frame_aligned(struct snd_pcm_runtime *runtime, ssize_t bytes) … … 744 754 * snd_pcm_lib_buffer_bytes - Get the buffer size of the current PCM in bytes 745 755 * @substream: PCM substream 756 * 757 * Return: buffer byte size 746 758 */ 747 759 static inline size_t snd_pcm_lib_buffer_bytes(struct snd_pcm_substream *substream) … … 754 766 * snd_pcm_lib_period_bytes - Get the period size of the current PCM in bytes 755 767 * @substream: PCM substream 768 * 769 * Return: period byte size 756 770 */ 757 771 static inline size_t snd_pcm_lib_period_bytes(struct snd_pcm_substream *substream) … … 766 780 * 767 781 * Result is between 0 ... (boundary - 1) 782 * 783 * Return: available frame size 768 784 */ 769 785 static inline snd_pcm_uframes_t snd_pcm_playback_avail(struct snd_pcm_runtime *runtime) … … 795 811 * 796 812 * Result is between 0 ... (boundary - 1) 813 * 814 * Return: available frame size 797 815 */ 798 816 static inline snd_pcm_uframes_t snd_pcm_capture_avail(struct snd_pcm_runtime *runtime) … … 807 825 * snd_pcm_playback_hw_avail - Get the queued space for playback 808 826 * @runtime: PCM runtime instance 827 * 828 * Return: available frame size 809 829 */ 810 830 static inline snd_pcm_sframes_t snd_pcm_playback_hw_avail(struct snd_pcm_runtime *runtime) … … 816 836 * snd_pcm_capture_hw_avail - Get the free space for capture 817 837 * @runtime: PCM runtime instance 838 * 839 * Return: available frame size 818 840 */ 819 841 static inline snd_pcm_sframes_t snd_pcm_capture_hw_avail(struct snd_pcm_runtime *runtime) … … 955 977 * params_channels - Get the number of channels from the hw params 956 978 * @p: hw params 979 * 980 * Return: the number of channels 957 981 */ 958 982 static inline unsigned int params_channels(const struct snd_pcm_hw_params *p) … … 964 988 * params_rate - Get the sample rate from the hw params 965 989 * @p: hw params 990 * 991 * Return: the sample rate 966 992 */ 967 993 static inline unsigned int params_rate(const struct snd_pcm_hw_params *p) … … 973 999 * params_period_size - Get the period size (in frames) from the hw params 974 1000 * @p: hw params 1001 * 1002 * Return: the period size in frames 975 1003 */ 976 1004 static inline unsigned int params_period_size(const struct snd_pcm_hw_params *p) … … 982 1010 * params_periods - Get the number of periods from the hw params 983 1011 * @p: hw params 1012 * 1013 * Return: the number of periods 984 1014 */ 985 1015 static inline unsigned int params_periods(const struct snd_pcm_hw_params *p) … … 991 1021 * params_buffer_size - Get the buffer size (in frames) from the hw params 992 1022 * @p: hw params 1023 * 1024 * Return: the buffer size in frames 993 1025 */ 994 1026 static inline unsigned int params_buffer_size(const struct snd_pcm_hw_params *p) … … 1000 1032 * params_buffer_bytes - Get the buffer size (in bytes) from the hw params 1001 1033 * @p: hw params 1034 * 1035 * Return: the buffer size in bytes 1002 1036 */ 1003 1037 static inline unsigned int params_buffer_bytes(const struct snd_pcm_hw_params *p) … … 1262 1296 * allocation of a larger buffer unlike the standard one. 1263 1297 * The function may return -ENOMEM error, hence the caller must check it. 1298 * 1299 * Return: zero if successful, or a negative error code 1264 1300 */ 1265 1301 static inline int __must_check … … 1280 1316 * all substream. If any of allocation fails, it returns -ENOMEM, hence the 1281 1317 * caller must check the return value. 1318 * 1319 * Return: zero if successful, or a negative error code 1282 1320 */ 1283 1321 static inline int __must_check … … 1336 1374 * @substream: PCM substream 1337 1375 * @ofs: byte offset 1376 * 1377 * Return: DMA address 1338 1378 */ 1339 1379 static inline dma_addr_t … … 1349 1389 * @ofs: byte offset 1350 1390 * @size: byte size to examine 1391 * 1392 * Return: chunk size 1351 1393 */ 1352 1394 static inline unsigned int … … 1414 1456 1415 1457 /** 1416 * snd_pcm_ stream_str- Get a string naming the direction of a stream1417 * @ substream: the pcm substream instance1418 * 1419 * Return : Astring naming the direction of the stream.1420 */ 1421 static inline const char *snd_pcm_ stream_str(struct snd_pcm_substream *substream)1422 { 1423 if ( substream->stream== SNDRV_PCM_STREAM_PLAYBACK)1458 * snd_pcm_direction_name - Get a string naming the direction of a stream 1459 * @direction: Stream's direction, one of SNDRV_PCM_STREAM_XXX 1460 * 1461 * Returns a string naming the direction of the stream. 1462 */ 1463 static inline const char *snd_pcm_direction_name(int direction) 1464 { 1465 if (direction == SNDRV_PCM_STREAM_PLAYBACK) 1424 1466 return "Playback"; 1425 1467 else 1426 1468 return "Capture"; 1469 } 1470 1471 /** 1472 * snd_pcm_stream_str - Get a string naming the direction of a stream 1473 * @substream: the pcm substream instance 1474 * 1475 * Return: A string naming the direction of the stream. 1476 */ 1477 static inline const char *snd_pcm_stream_str(struct snd_pcm_substream *substream) 1478 { 1479 return snd_pcm_direction_name(substream->stream); 1427 1480 } 1428 1481 … … 1451 1504 * @info: chmap information 1452 1505 * @idx: the substream number index 1506 * 1507 * Return: the matched PCM substream, or NULL if not found 1453 1508 */ 1454 1509 static inline struct snd_pcm_substream * … … 1481 1536 * pcm_format_to_bits - Strong-typed conversion of pcm_format to bitwise 1482 1537 * @pcm_format: PCM format 1538 * 1539 * Return: 64bit mask corresponding to the given PCM format 1483 1540 */ 1484 1541 static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format) -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/rawmidi.h
r710 r750 64 64 int buffer_ref; /* buffer reference count */ 65 65 /* misc */ 66 spinlock_t lock;67 66 wait_queue_head_t sleep; 68 67 /* event handler (new bytes, input only) */ … … 86 85 int use_count; /* use counter (for output) */ 87 86 size_t bytes; 87 spinlock_t lock; 88 88 struct snd_rawmidi *rmidi; 89 89 struct snd_rawmidi_str *pstr; … … 157 157 int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream, 158 158 unsigned char *buffer, int count); 159 int __snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream,160 unsigned char *buffer, int count);161 int __snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream,162 int count);163 159 int snd_rawmidi_proceed(struct snd_rawmidi_substream *substream); 164 160 -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/simple_card_utils.h
r738 r750 52 52 int codecs; 53 53 int platforms; 54 int c2c;55 54 }; 56 55 … … 65 64 struct asoc_simple_data adata; 66 65 struct snd_soc_codec_conf *codec_conf; 67 struct snd_soc_pcm_stream *c2c_conf;68 66 struct prop_nums num; 69 67 unsigned int mclk_fs; … … 76 74 struct snd_soc_dai_link_component dummy; 77 75 struct snd_soc_codec_conf *codec_conf; 78 struct snd_soc_pcm_stream *c2c_conf;79 76 struct gpio_desc *pa_gpio; 80 77 const struct snd_soc_ops *ops; … … 174 171 int is_single_links); 175 172 176 intasoc_simple_clean_reference(struct snd_soc_card *card);173 void asoc_simple_clean_reference(struct snd_soc_card *card); 177 174 178 175 void asoc_simple_convert_fixup(struct asoc_simple_data *data, -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/soc-acpi-intel-match.h
r692 r750 31 31 extern struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[]; 32 32 extern struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[]; 33 extern struct snd_soc_acpi_mach snd_soc_acpi_intel_mtl_machines[]; 33 34 34 35 extern struct snd_soc_acpi_mach snd_soc_acpi_intel_cnl_sdw_machines[]; … … 38 39 extern struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_sdw_machines[]; 39 40 extern struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_sdw_machines[]; 41 extern struct snd_soc_acpi_mach snd_soc_acpi_intel_mtl_sdw_machines[]; 40 42 41 43 /* -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/soc-component.h
r739 r750 180 180 */ 181 181 unsigned int endianness:1; 182 unsigned int non_legacy_dai_naming:1;182 unsigned int legacy_dai_naming:1; 183 183 184 184 /* this component uses topology and ignore machine driver FEs */ … … 347 347 { 348 348 return regcache_sync(component->regmap); 349 }350 351 static inline int snd_soc_component_is_codec(struct snd_soc_component *component)352 {353 return component->driver->non_legacy_dai_naming;354 349 } 355 350 -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/soc-dai.h
r737 r750 124 124 #define SND_SOC_DAIFMT_CBM_CFS SND_SOC_DAIFMT_CBP_CFC 125 125 #define SND_SOC_DAIFMT_CBS_CFS SND_SOC_DAIFMT_CBC_CFC 126 127 /* when passed to set_fmt directly indicate if the device is provider or consumer */ 128 #define SND_SOC_DAIFMT_BP_FP SND_SOC_DAIFMT_CBP_CFP 129 #define SND_SOC_DAIFMT_BC_FP SND_SOC_DAIFMT_CBC_CFP 130 #define SND_SOC_DAIFMT_BP_FC SND_SOC_DAIFMT_CBP_CFC 131 #define SND_SOC_DAIFMT_BC_FC SND_SOC_DAIFMT_CBC_CFC 126 132 127 133 /* Describes the possible PCM format */ -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/soc.h
r739 r750 137 137 .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \ 138 138 max, invert, 0) } 139 #define SOC_DOUBLE_SX_TLV(xname, xreg, shift_left, shift_right, xmin, xmax, tlv_array) \ 140 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ 141 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ 142 SNDRV_CTL_ELEM_ACCESS_READWRITE, \ 143 .tlv.p = (tlv_array), \ 144 .info = snd_soc_info_volsw_sx, \ 145 .get = snd_soc_get_volsw_sx, \ 146 .put = snd_soc_put_volsw_sx, \ 147 .private_value = (unsigned long)&(struct soc_mixer_control) \ 148 {.reg = xreg, .rreg = xreg, \ 149 .shift = shift_left, .rshift = shift_right, \ 150 .max = xmax, .min = xmin} } 139 151 #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \ 140 152 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ … … 415 427 416 428 int snd_soc_register_card(struct snd_soc_card *card); 417 intsnd_soc_unregister_card(struct snd_soc_card *card);429 void snd_soc_unregister_card(struct snd_soc_card *card); 418 430 int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card); 419 431 #ifdef CONFIG_PM_SLEEP … … 915 927 int (*probe)(struct snd_soc_card *card); 916 928 int (*late_probe)(struct snd_soc_card *card); 929 void (*fixup_controls)(struct snd_soc_card *card); 917 930 int (*remove)(struct snd_soc_card *card); 918 931 -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/sof.h
r739 r750 139 139 struct snd_sof_dsp_ops *ops; 140 140 int (*ops_init)(struct snd_sof_dev *sdev); 141 void (*ops_free)(struct snd_sof_dev *sdev); 141 142 }; 142 143 -
GPL/branches/uniaud32-exp/alsa-kernel/include/sound/version.h
r749 r750 1 1 /* include/version.h */ 2 #define CONFIG_SND_VERSION " 5.19.12"2 #define CONFIG_SND_VERSION "6.0" 3 3 #define CONFIG_SND_DATE "" -
GPL/branches/uniaud32-exp/alsa-kernel/include/uapi/sound/asound.h
r737 r750 1150 1150 unsigned int length; /* in bytes aligned to 4 */ 1151 1151 #ifndef TARGET_OS2 1152 unsigned int tlv[ 0]; /* first TLV */1152 unsigned int tlv[]; /* first TLV */ 1153 1153 #else 1154 1154 unsigned int tlv[1]; /* first TLV */ -
GPL/branches/uniaud32-exp/alsa-kernel/include/uapi/sound/compress_offload.h
r629 r750 124 124 125 125 /** 126 * enum sndrv_compress_encoder 126 * enum sndrv_compress_encoder - encoder metadata key 127 127 * @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the 128 128 * end of the track -
GPL/branches/uniaud32-exp/alsa-kernel/include/uapi/sound/compress_params.h
r629 r750 251 251 252 252 /** 253 * struct snd_enc_vorbis 253 * struct snd_enc_vorbis - Vorbis encoder parameters 254 254 * @quality: Sets encoding quality to n, between -1 (low) and 10 (high). 255 255 * In the default mode of operation, the quality level is 3. … … 280 280 281 281 /** 282 * struct snd_enc_real 282 * struct snd_enc_real - RealAudio encoder parameters 283 283 * @quant_bits: number of coupling quantization bits in the stream 284 284 * @start_region: coupling start region in the stream … … 295 295 296 296 /** 297 * struct snd_enc_flac 297 * struct snd_enc_flac - FLAC encoder parameters 298 298 * @num: serial number, valid only for OGG formats 299 299 * needs to be set by application -
GPL/branches/uniaud32-exp/alsa-kernel/pci/emu10k1/memory.c
r697 r750 325 325 } 326 326 /* fill buffer addresses but pointers are not stored so that 327 * snd_free_pci_page() is not called in insynth_free()327 * snd_free_pci_page() is not called in synth_free() 328 328 */ 329 329 idx = 0; -
GPL/branches/uniaud32-exp/alsa-kernel/pci/ens1370.c
r737 r750 9 9 * for ens1371 only ( FIXME ) 10 10 * derived from cs4281.c, atiixp.c and via82xx.c 11 * using http ://www.alsa-project.org/~tiwai/writing-an-alsa-driver/11 * using https://www.kernel.org/doc/html/latest/sound/kernel-api/writing-an-alsa-driver.html 12 12 * by Kurt J. Bosch 13 13 */ -
GPL/branches/uniaud32-exp/alsa-kernel/pci/hda/hda_bind.c
r749 r750 253 253 hda_nid_t nid; 254 254 255 /* 256 * For ASoC users, if snd_hda_hdmi_codec module is denylisted and any 257 * event causes i915 enumeration to fail, ->wcaps remains uninitialized. 258 */ 259 if (!codec->wcaps) 260 return true; 261 255 262 for_each_hda_codec_node(nid, codec) { 256 263 unsigned int wcaps = get_wcaps(codec, nid); -
GPL/branches/uniaud32-exp/alsa-kernel/pci/hda/hda_codec.c
r739 r750 785 785 void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec) 786 786 { 787 if (codec-> registered) {787 if (codec->core.registered) { 788 788 /* pm_runtime_put() is called in snd_hdac_device_exit() */ 789 789 pm_runtime_get_noresume(hda_codec_dev(codec)); 790 790 pm_runtime_disable(hda_codec_dev(codec)); 791 codec-> registered = 0;791 codec->core.registered = 0; 792 792 } 793 793 … … 838 838 void snd_hda_codec_register(struct hda_codec *codec) 839 839 { 840 if (codec-> registered)840 if (codec->core.registered) 841 841 return; 842 842 if (device_is_registered(hda_codec_dev(codec))) { … … 845 845 /* it was powered up in snd_hda_codec_new(), now all done */ 846 846 snd_hda_power_down(codec); 847 codec-> registered = 1;847 codec->core.registered = 1; 848 848 } 849 849 } … … 963 963 { 964 964 struct hda_codec *codec; 965 int ret; 965 966 966 967 codec = snd_hda_codec_device_init(bus, codec_addr, "hdaudioC%dD%d", … … 970 971 *codecp = codec; 971 972 972 return snd_hda_codec_device_new(bus, card, codec_addr, *codecp, true); 973 ret = snd_hda_codec_device_new(bus, card, codec_addr, *codecp, true); 974 if (ret) 975 put_device(hda_codec_dev(*codecp)); 976 977 return ret; 973 978 } 974 979 EXPORT_SYMBOL_GPL(snd_hda_codec_new); … … 1025 1030 if (codec->bus->modelname) { 1026 1031 codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL); 1027 if (!codec->modelname) { 1028 err = -ENOMEM; 1029 goto error; 1030 } 1032 if (!codec->modelname) 1033 return -ENOMEM; 1031 1034 } 1032 1035 … … 1034 1037 err = read_widget_caps(codec, fg); 1035 1038 if (err < 0) 1036 goto error;1039 return err; 1037 1040 err = read_pin_defaults(codec); 1038 1041 if (err < 0) 1039 goto error;1042 return err; 1040 1043 1041 1044 /* power-up all before initialization */ … … 1055 1058 err = snd_device_new(card, SNDRV_DEV_CODEC, codec, &dev_ops); 1056 1059 if (err < 0) 1057 goto error; 1058 } 1059 1060 return err; 1061 } 1062 1063 #ifdef CONFIG_PM 1060 1064 /* PM runtime needs to be enabled later after binding codec */ 1061 pm_runtime_forbid(&codec->core.dev); 1062 1063 return 0; 1064 1065 error: 1066 put_device(hda_codec_dev(codec)); 1067 return err; 1065 if (codec->core.dev.power.runtime_auto) 1066 pm_runtime_forbid(&codec->core.dev); 1067 else 1068 /* Keep the usage_count consistent across subsequent probing */ 1069 pm_runtime_get_noresume(&codec->core.dev); 1070 #endif 1071 1072 return 0; 1068 1073 } 1069 1074 EXPORT_SYMBOL_GPL(snd_hda_codec_device_new); … … 3067 3072 3068 3073 /* Skip the shutdown if codec is not registered */ 3069 if (!codec-> registered)3074 if (!codec->core.registered) 3070 3075 return; 3071 3076 -
GPL/branches/uniaud32-exp/alsa-kernel/pci/hda/hda_component2.h
r737 r750 15 15 struct device *dev; 16 16 char name[HDA_MAX_NAME_SIZE]; 17 struct hda_codec *codec; 17 18 void (*playback_hook)(struct device *dev, int action); 18 int (*s et_channel_map)(struct device *dev, unsigned int rx_num, unsigned int *rx_slot,19 unsigned int tx_num, unsigned int *tx_slot);19 int (*suspend_hook)(struct device *dev); 20 int (*resume_hook)(struct device *dev); 20 21 }; -
GPL/branches/uniaud32-exp/alsa-kernel/pci/hda/hda_sysfs.c
r629 r750 34 34 struct hda_codec *codec = dev_get_drvdata(dev); 35 35 snd_hda_update_power_acct(codec); 36 return s printf(buf, "%u\n", jiffies_to_msecs(codec->power_on_acct));36 return sysfs_emit(buf, "%u\n", jiffies_to_msecs(codec->power_on_acct)); 37 37 } 38 38 … … 43 43 struct hda_codec *codec = dev_get_drvdata(dev); 44 44 snd_hda_update_power_acct(codec); 45 return s printf(buf, "%u\n", jiffies_to_msecs(codec->power_off_acct));45 return sysfs_emit(buf, "%u\n", jiffies_to_msecs(codec->power_off_acct)); 46 46 } 47 47 … … 56 56 { \ 57 57 struct hda_codec *codec = dev_get_drvdata(dev); \ 58 return s printf(buf, "0x%x\n", codec->field); \58 return sysfs_emit(buf, "0x%x\n", codec->field); \ 59 59 } 60 60 … … 65 65 { \ 66 66 struct hda_codec *codec = dev_get_drvdata(dev); \ 67 return s printf(buf, "%s\n", \68 67 return sysfs_emit(buf, "%s\n", \ 68 codec->field ? codec->field : ""); \ 69 69 } 70 70 … … 86 86 mutex_lock(&codec->user_mutex); 87 87 snd_array_for_each(list, i, pin) { 88 len += s printf(buf +len, "0x%02x 0x%08x\n",89 88 len += sysfs_emit_at(buf, len, "0x%02x 0x%08x\n", 89 pin->nid, pin->cfg); 90 90 } 91 91 mutex_unlock(&codec->user_mutex); … … 223 223 mutex_lock(&codec->user_mutex); 224 224 snd_array_for_each(&codec->init_verbs, i, v) { 225 len += scnprintf(buf + len, PAGE_SIZE - len, 226 "0x%02x 0x%03x 0x%04x\n", 227 v->nid, v->verb, v->param); 225 len += sysfs_emit_at(buf, len, "0x%02x 0x%03x 0x%04x\n", 226 v->nid, v->verb, v->param); 228 227 } 229 228 mutex_unlock(&codec->user_mutex); … … 273 272 mutex_lock(&codec->user_mutex); 274 273 snd_array_for_each(&codec->hints, i, hint) { 275 len += s cnprintf(buf + len, PAGE_SIZE - len,276 "%s = %s\n",hint->key, hint->val);274 len += sysfs_emit_at(buf, len, "%s = %s\n", 275 hint->key, hint->val); 277 276 } 278 277 mutex_unlock(&codec->user_mutex); -
GPL/branches/uniaud32-exp/alsa-kernel/pci/hda/patch_hdmi.c
r749 r750 1291 1291 per_pin = get_pin(spec, pin_idx); 1292 1292 per_pin->cvt_nid = per_cvt->cvt_nid; 1293 per_pin->silent_stream = false; 1293 1294 hinfo->nid = per_cvt->cvt_nid; 1294 1295 -
GPL/branches/uniaud32-exp/alsa-kernel/pci/hda/patch_realtek.c
r749 r750 3755 3755 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); 3756 3756 3757 for (i = 0; i < HDA_MAX_COMPONENTS; i++) 3758 if (spec->comps[i].resume_hook) 3759 spec->comps[i].resume_hook(spec->comps[i].dev); 3760 3757 3761 return 0; 3758 3762 … … 4676 4680 { 4677 4681 //NOT_USED struct alc_spec *spec = codec->spec; 4682 int i; 4678 4683 4679 4684 #ifndef TARGET_OS2 4680 4685 if (spec->has_alc5505_dsp) 4681 4686 alc5505_dsp_suspend(codec); 4687 4688 for (i = 0; i < HDA_MAX_COMPONENTS; i++) 4689 if (spec->comps[i].suspend_hook) 4690 spec->comps[i].suspend_hook(spec->comps[i].dev); 4682 4691 #endif 4683 4692 return alc_suspend(codec); … … 4687 4696 { 4688 4697 struct alc_spec *spec = codec->spec; 4698 int i; 4689 4699 4690 4700 if (spec->codec_variant == ALC269_TYPE_ALC269VB) … … 7354 7364 struct hda_codec *cdc = dev_to_hda_codec(dev); 7355 7365 struct alc_spec *spec = cdc->spec; 7356 7357 return component_bind_all(dev, spec->comps); 7366 int ret, i; 7367 7368 ret = component_bind_all(dev, spec->comps); 7369 if (ret) 7370 return ret; 7371 7372 if (snd_hdac_is_power_on(&cdc->core)) { 7373 codec_dbg(cdc, "Resuming after bind.\n"); 7374 for (i = 0; i < HDA_MAX_COMPONENTS; i++) 7375 if (spec->comps[i].resume_hook) 7376 spec->comps[i].resume_hook(spec->comps[i].dev); 7377 } 7378 7379 return 0; 7358 7380 } 7359 7381 … … 7398 7420 if (!name) 7399 7421 return; 7422 spec->comps[i].codec = cdc; 7400 7423 component_match_add(dev, &spec->match, component_compare_dev_name, name); 7401 7424 } … … 7428 7451 { 7429 7452 cs35l41_generic_fixup(cdc, action, "i2c", "CLSA0100", 2); 7453 } 7454 7455 static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const struct hda_fixup *fix, 7456 int action) 7457 { 7458 cs35l41_generic_fixup(cdc, action, "i2c", "CLSA0101", 2); 7430 7459 } 7431 7460 … … 7808 7837 ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED, 7809 7838 ALC295_FIXUP_FRAMEWORK_LAPTOP_MIC_NO_PRESENCE, 7839 ALC287_FIXUP_LEGION_16ITHG6, 7810 7840 ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK, 7811 7841 ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN, … … 10008 10038 .chained = true, 10009 10039 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC 10040 }, 10041 [ALC287_FIXUP_LEGION_16ITHG6] = { 10042 .type = HDA_FIXUP_FUNC, 10043 .v.func = alc287_fixup_legion_16ithg6_speakers, 10010 10044 }, 10011 10045 [ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK] = { … … 10559 10593 SND_PCI_QUIRK(0x17aa, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), 10560 10594 SND_PCI_QUIRK(0x17aa, 0x3853, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), 10595 SND_PCI_QUIRK(0x17aa, 0x3855, "Legion 7 16ITHG6", ALC287_FIXUP_LEGION_16ITHG6), 10596 SND_PCI_QUIRK(0x17aa, 0x3869, "Lenovo Yoga7 14IAL7", ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN), 10561 10597 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI), 10562 10598 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC), -
GPL/branches/uniaud32-exp/include/linux/pm.h
r711 r750 247 247 struct list_head entry; 248 248 enum rpm_status runtime_status; 249 unsigned int runtime_auto:1; 249 250 }; 250 251 -
GPL/branches/uniaud32-exp/lib32/misc.c
r737 r750 40 40 #include <linux/firmware.h> 41 41 #include <linux/ctype.h> 42 #include <linux/math64.h> 42 43 #include <dbgos2.h> 43 44 … … 823 824 } 824 825 EXPORT_SYMBOL(sysfs_streq); 826 827 u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder) 828 { 829 u32 high = divisor >> 32; 830 u64 quot; 831 832 if (high == 0) { 833 u32 rem32; 834 quot = div_u64_rem(dividend, divisor, &rem32); 835 *remainder = rem32; 836 } else { 837 int n = fls(high); 838 quot = div_u64(dividend >> n, divisor >> n); 839 840 if (quot != 0) 841 quot--; 842 843 *remainder = dividend - quot * divisor; 844 if (*remainder >= divisor) { 845 quot++; 846 *remainder -= divisor; 847 } 848 } 849 850 return quot; 851 } 852 853 /** 854 * memset32() - Fill a memory area with a uint32_t 855 * @s: Pointer to the start of the area. 856 * @v: The value to fill the area with 857 * @count: The number of values to store 858 * 859 * Differs from memset() in that it fills with a uint32_t instead 860 * of a byte. Remember that @count is the number of uint32_ts to 861 * store, not the number of bytes. 862 */ 863 void *memset32(uint32_t *s, uint32_t v, size_t count) 864 { 865 uint32_t *xs = s; 866 867 while (count--) 868 *xs++ = v; 869 return s; 870 } 871 EXPORT_SYMBOL(memset32); 872 873 /** 874 * sysfs_emit - scnprintf equivalent, aware of PAGE_SIZE buffer. 875 * @buf: start of PAGE_SIZE buffer. 876 * @fmt: format 877 * @...: optional arguments to @format 878 * 879 * 880 * Returns number of characters written to @buf. 881 */ 882 int sysfs_emit(char *buf, const char *fmt, ...) 883 { 884 va_list args; 885 int len; 886 887 #ifdef NOT_USED 888 if (WARN(!buf || offset_in_page(buf), 889 "invalid sysfs_emit: buf:%p\n", buf)) 890 return 0; 891 #endif 892 893 va_start(args, fmt); 894 len = vscnprintf(buf, PAGE_SIZE, fmt, args); 895 va_end(args); 896 897 return len; 898 } 899 EXPORT_SYMBOL_GPL(sysfs_emit); 900 901 /** 902 * sysfs_emit_at - scnprintf equivalent, aware of PAGE_SIZE buffer. 903 * @buf: start of PAGE_SIZE buffer. 904 * @at: offset in @buf to start write in bytes 905 * @at must be >= 0 && < PAGE_SIZE 906 * @fmt: format 907 * @...: optional arguments to @fmt 908 * 909 * 910 * Returns number of characters written starting at &@buf[@at]. 911 */ 912 int sysfs_emit_at(char *buf, int at, const char *fmt, ...) 913 { 914 va_list args; 915 int len; 916 917 #ifdef NOT_USED 918 if (WARN(!buf || offset_in_page(buf) || at < 0 || at >= PAGE_SIZE, 919 "invalid sysfs_emit_at: buf:%p at:%d\n", buf, at)) 920 return 0; 921 #endif 922 923 va_start(args, fmt); 924 len = vscnprintf(buf + at, PAGE_SIZE - at, fmt, args); 925 va_end(args); 926 927 return len; 928 } 929 EXPORT_SYMBOL_GPL(sysfs_emit_at); -
GPL/branches/uniaud32-exp/lib32/vsprintf.c
r32 r750 32 32 33 33 #include <stdarg.h> 34 34 #include <linux/kernel.h> 35 35 36 36 … … 366 366 } 367 367 368 /** 369 * vscnprintf - Format a string and place it in a buffer 370 * @buf: The buffer to place the result into 371 * @size: The size of the buffer, including the trailing null space 372 * @fmt: The format string to use 373 * @args: Arguments for the format string 374 * 375 * The return value is the number of characters which have been written into 376 * the @buf not including the trailing '\0'. If @size is == 0 the function 377 * returns 0. 378 * 379 * If you're not already dealing with a va_list consider using scnprintf(). 380 * 381 * See the vsnprintf() documentation for format string extensions over C99. 382 */ 383 int vscnprintf(char *buf, size_t size, const char *fmt, va_list args) 384 { 385 int i; 386 387 if (unlikely(!size)) 388 return 0; 389 390 i = vsnprintf(buf, size, fmt, args); 391 392 if (likely(i < size)) 393 return i; 394 395 return size - 1; 396 }
Note:
See TracChangeset
for help on using the changeset viewer.