~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/ac97_bus.c

Version: ~ [ linux-6.4-rc3 ] ~ [ linux-6.3.4 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.30 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.113 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.180 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.243 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.283 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.315 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Linux driver model AC97 bus interface
  3  *
  4  * Author:      Nicolas Pitre
  5  * Created:     Jan 14, 2005
  6  * Copyright:   (C) MontaVista Software Inc.
  7  *
  8  * This program is free software; you can redistribute it and/or modify
  9  * it under the terms of the GNU General Public License as published by
 10  * the Free Software Foundation; either version 2 of the License, or
 11  * (at your option) any later version.
 12  */
 13 
 14 #include <linux/module.h>
 15 #include <linux/init.h>
 16 #include <linux/device.h>
 17 #include <linux/string.h>
 18 #include <sound/ac97_codec.h>
 19 
 20 /*
 21  * snd_ac97_check_id() - Reads and checks the vendor ID of the device
 22  * @ac97: The AC97 device to check
 23  * @id: The ID to compare to
 24  * @id_mask: Mask that is applied to the device ID before comparing to @id
 25  *
 26  * If @id is 0 this function returns true if the read device vendor ID is
 27  * a valid ID. If @id is non 0 this functions returns true if @id
 28  * matches the read vendor ID. Otherwise the function returns false.
 29  */
 30 static bool snd_ac97_check_id(struct snd_ac97 *ac97, unsigned int id,
 31         unsigned int id_mask)
 32 {
 33         ac97->id = ac97->bus->ops->read(ac97, AC97_VENDOR_ID1) << 16;
 34         ac97->id |= ac97->bus->ops->read(ac97, AC97_VENDOR_ID2);
 35 
 36         if (ac97->id == 0x0 || ac97->id == 0xffffffff)
 37                 return false;
 38 
 39         if (id != 0 && id != (ac97->id & id_mask))
 40                 return false;
 41 
 42         return true;
 43 }
 44 
 45 /**
 46  * snd_ac97_reset() - Reset AC'97 device
 47  * @ac97: The AC'97 device to reset
 48  * @try_warm: Try a warm reset first
 49  * @id: Expected device vendor ID
 50  * @id_mask: Mask that is applied to the device ID before comparing to @id
 51  *
 52  * This function resets the AC'97 device. If @try_warm is true the function
 53  * first performs a warm reset. If the warm reset is successful the function
 54  * returns 1. Otherwise or if @try_warm is false the function issues cold reset
 55  * followed by a warm reset. If this is successful the function returns 0,
 56  * otherwise a negative error code. If @id is 0 any valid device ID will be
 57  * accepted, otherwise only the ID that matches @id and @id_mask is accepted.
 58  */
 59 int snd_ac97_reset(struct snd_ac97 *ac97, bool try_warm, unsigned int id,
 60         unsigned int id_mask)
 61 {
 62         struct snd_ac97_bus_ops *ops = ac97->bus->ops;
 63 
 64         if (try_warm && ops->warm_reset) {
 65                 ops->warm_reset(ac97);
 66                 if (snd_ac97_check_id(ac97, id, id_mask))
 67                         return 1;
 68         }
 69 
 70         if (ops->reset)
 71                 ops->reset(ac97);
 72         if (ops->warm_reset)
 73                 ops->warm_reset(ac97);
 74 
 75         if (snd_ac97_check_id(ac97, id, id_mask))
 76                 return 0;
 77 
 78         return -ENODEV;
 79 }
 80 EXPORT_SYMBOL_GPL(snd_ac97_reset);
 81 
 82 /*
 83  * Let drivers decide whether they want to support given codec from their
 84  * probe method. Drivers have direct access to the struct snd_ac97
 85  * structure and may  decide based on the id field amongst other things.
 86  */
 87 static int ac97_bus_match(struct device *dev, struct device_driver *drv)
 88 {
 89         return 1;
 90 }
 91 
 92 struct bus_type ac97_bus_type = {
 93         .name           = "ac97",
 94         .match          = ac97_bus_match,
 95 };
 96 
 97 static int __init ac97_bus_init(void)
 98 {
 99         return bus_register(&ac97_bus_type);
100 }
101 
102 subsys_initcall(ac97_bus_init);
103 
104 static void __exit ac97_bus_exit(void)
105 {
106         bus_unregister(&ac97_bus_type);
107 }
108 
109 module_exit(ac97_bus_exit);
110 
111 EXPORT_SYMBOL(ac97_bus_type);
112 
113 MODULE_LICENSE("GPL");
114 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp