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

TOMOYO Linux Cross Reference
Linux/sound/usb/power.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /sound/usb/power.c (Version linux-6.12-rc7) and /sound/usb/power.c (Version linux-4.20.17)


  1 // SPDX-License-Identifier: GPL-2.0                 1 // SPDX-License-Identifier: GPL-2.0
  2 /*                                                  2 /*
  3  *   UAC3 Power Domain state management functi      3  *   UAC3 Power Domain state management functions
  4  */                                                 4  */
  5                                                     5 
  6 #include <linux/slab.h>                             6 #include <linux/slab.h>
  7 #include <linux/usb.h>                              7 #include <linux/usb.h>
  8 #include <linux/usb/audio.h>                        8 #include <linux/usb/audio.h>
  9 #include <linux/usb/audio-v2.h>                     9 #include <linux/usb/audio-v2.h>
 10 #include <linux/usb/audio-v3.h>                    10 #include <linux/usb/audio-v3.h>
 11                                                    11 
 12 #include "usbaudio.h"                              12 #include "usbaudio.h"
 13 #include "helper.h"                                13 #include "helper.h"
 14 #include "power.h"                                 14 #include "power.h"
 15                                                    15 
 16 struct snd_usb_power_domain *                      16 struct snd_usb_power_domain *
 17 snd_usb_find_power_domain(struct usb_host_inte     17 snd_usb_find_power_domain(struct usb_host_interface *ctrl_iface,
 18                           unsigned char id)        18                           unsigned char id)
 19 {                                                  19 {
 20         struct snd_usb_power_domain *pd;           20         struct snd_usb_power_domain *pd;
 21         void *p;                                   21         void *p;
 22                                                    22 
 23         pd = kzalloc(sizeof(*pd), GFP_KERNEL);     23         pd = kzalloc(sizeof(*pd), GFP_KERNEL);
 24         if (!pd)                                   24         if (!pd)
 25                 return NULL;                       25                 return NULL;
 26                                                    26 
 27         p = NULL;                                  27         p = NULL;
 28         while ((p = snd_usb_find_csint_desc(ct     28         while ((p = snd_usb_find_csint_desc(ctrl_iface->extra,
 29                                             ct     29                                             ctrl_iface->extralen,
 30                                             p,     30                                             p, UAC3_POWER_DOMAIN)) != NULL) {
 31                 struct uac3_power_domain_descr     31                 struct uac3_power_domain_descriptor *pd_desc = p;
 32                 int i;                             32                 int i;
 33                                                    33 
 34                 if (!snd_usb_validate_audio_de << 
 35                         continue;              << 
 36                 for (i = 0; i < pd_desc->bNrEn     34                 for (i = 0; i < pd_desc->bNrEntities; i++) {
 37                         if (pd_desc->baEntityI     35                         if (pd_desc->baEntityID[i] == id) {
 38                                 pd->pd_id = pd     36                                 pd->pd_id = pd_desc->bPowerDomainID;
 39                                 pd->pd_d1d0_re     37                                 pd->pd_d1d0_rec =
 40                                         le16_t     38                                         le16_to_cpu(pd_desc->waRecoveryTime1);
 41                                 pd->pd_d2d0_re     39                                 pd->pd_d2d0_rec =
 42                                         le16_t     40                                         le16_to_cpu(pd_desc->waRecoveryTime2);
 43                                 pd->ctrl_iface << 
 44                                 return pd;         41                                 return pd;
 45                         }                          42                         }
 46                 }                                  43                 }
 47         }                                          44         }
 48                                                    45 
 49         kfree(pd);                                 46         kfree(pd);
 50         return NULL;                               47         return NULL;
 51 }                                                  48 }
 52                                                    49 
 53 int snd_usb_power_domain_set(struct snd_usb_au     50 int snd_usb_power_domain_set(struct snd_usb_audio *chip,
 54                              struct snd_usb_po     51                              struct snd_usb_power_domain *pd,
 55                              unsigned char sta     52                              unsigned char state)
 56 {                                                  53 {
 57         struct usb_device *dev = chip->dev;        54         struct usb_device *dev = chip->dev;
 58         unsigned char current_state;               55         unsigned char current_state;
 59         int err, idx;                              56         int err, idx;
 60                                                    57 
 61         idx = snd_usb_ctrl_intf(pd->ctrl_iface !!  58         idx = snd_usb_ctrl_intf(chip) | (pd->pd_id << 8);
 62                                                    59 
 63         err = snd_usb_ctl_msg(chip->dev, usb_r     60         err = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0),
 64                               UAC2_CS_CUR,         61                               UAC2_CS_CUR,
 65                               USB_RECIP_INTERF     62                               USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
 66                               UAC3_AC_POWER_DO     63                               UAC3_AC_POWER_DOMAIN_CONTROL << 8, idx,
 67                               &current_state,      64                               &current_state, sizeof(current_state));
 68         if (err < 0) {                             65         if (err < 0) {
 69                 dev_err(&dev->dev, "Can't get      66                 dev_err(&dev->dev, "Can't get UAC3 power state for id %d\n",
 70                         pd->pd_id);                67                         pd->pd_id);
 71                 return err;                        68                 return err;
 72         }                                          69         }
 73                                                    70 
 74         if (current_state == state) {              71         if (current_state == state) {
 75                 dev_dbg(&dev->dev, "UAC3 power     72                 dev_dbg(&dev->dev, "UAC3 power domain id %d already in state %d\n",
 76                         pd->pd_id, state);         73                         pd->pd_id, state);
 77                 return 0;                          74                 return 0;
 78         }                                          75         }
 79                                                    76 
 80         err = snd_usb_ctl_msg(chip->dev, usb_s     77         err = snd_usb_ctl_msg(chip->dev, usb_sndctrlpipe(chip->dev, 0), UAC2_CS_CUR,
 81                               USB_RECIP_INTERF     78                               USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
 82                               UAC3_AC_POWER_DO     79                               UAC3_AC_POWER_DOMAIN_CONTROL << 8, idx,
 83                               &state, sizeof(s     80                               &state, sizeof(state));
 84         if (err < 0) {                             81         if (err < 0) {
 85                 dev_err(&dev->dev, "Can't set      82                 dev_err(&dev->dev, "Can't set UAC3 power state to %d for id %d\n",
 86                         state, pd->pd_id);         83                         state, pd->pd_id);
 87                 return err;                        84                 return err;
 88         }                                          85         }
 89                                                    86 
 90         if (state == UAC3_PD_STATE_D0) {           87         if (state == UAC3_PD_STATE_D0) {
 91                 switch (current_state) {           88                 switch (current_state) {
 92                 case UAC3_PD_STATE_D2:             89                 case UAC3_PD_STATE_D2:
 93                         udelay(pd->pd_d2d0_rec     90                         udelay(pd->pd_d2d0_rec * 50);
 94                         break;                     91                         break;
 95                 case UAC3_PD_STATE_D1:             92                 case UAC3_PD_STATE_D1:
 96                         udelay(pd->pd_d1d0_rec     93                         udelay(pd->pd_d1d0_rec * 50);
 97                         break;                     94                         break;
 98                 default:                           95                 default:
 99                         return -EINVAL;            96                         return -EINVAL;
100                 }                                  97                 }
101         }                                          98         }
102                                                    99 
103         dev_dbg(&dev->dev, "UAC3 power domain     100         dev_dbg(&dev->dev, "UAC3 power domain id %d change to state %d\n",
104                 pd->pd_id, state);                101                 pd->pd_id, state);
105                                                   102 
106         return 0;                                 103         return 0;
107 }                                                 104 }
108                                                   105 

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php