Changeset 777 for GPL/trunk/alsa-kernel/hda/hdac_controller.c
- Timestamp:
- Apr 21, 2025, 7:17:25 PM (7 months ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
alsa-kernel/hda/hdac_controller.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-exp merged: 766-767,770-771,773-774
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/hda/hdac_controller.c
r772 r777 63 63 64 64 /* enable corb dma */ 65 if (!bus->use_pio_for_commands) 65 66 snd_hdac_chip_writeb(bus, CORBCTL, AZX_CORBCTL_RUN); 66 67 … … 136 137 } 137 138 138 /** 139 * snd_hdac_bus_send_cmd - send a command verb via CORB 139 /* receive an Immediate Response with PIO */ 140 static int snd_hdac_bus_wait_for_pio_response(struct hdac_bus *bus, 141 unsigned int addr) 142 { 143 int timeout = 50; 144 145 while (timeout--) { 146 /* check IRV bit */ 147 if (snd_hdac_chip_readw(bus, IRS) & AZX_IRS_VALID) { 148 /* reuse rirb.res as the response return value */ 149 bus->rirb.res[addr] = snd_hdac_chip_readl(bus, IR); 150 return 0; 151 } 152 udelay(1); 153 } 154 155 dev_dbg_ratelimited(bus->dev, "get_response_pio timeout: IRS=%#x\n", 156 snd_hdac_chip_readw(bus, IRS)); 157 158 bus->rirb.res[addr] = -1; 159 160 return -EIO; 161 } 162 163 /** 164 * snd_hdac_bus_send_cmd_pio - send a command verb via Immediate Command 140 165 * @bus: HD-audio core bus 141 166 * @val: encoded verb value to send … … 143 168 * Returns zero for success or a negative error code. 144 169 */ 145 int snd_hdac_bus_send_cmd(struct hdac_bus *bus, unsigned int val) 170 static int snd_hdac_bus_send_cmd_pio(struct hdac_bus *bus, unsigned int val) 171 { 172 unsigned int addr = azx_command_addr(val); 173 int timeout = 50; 174 int ret = -EIO; 175 176 spin_lock_irq(&bus->reg_lock); 177 178 while (timeout--) { 179 /* check ICB bit */ 180 if (!((snd_hdac_chip_readw(bus, IRS) & AZX_IRS_BUSY))) { 181 /* Clear IRV bit */ 182 snd_hdac_chip_updatew(bus, IRS, AZX_IRS_VALID, AZX_IRS_VALID); 183 snd_hdac_chip_writel(bus, IC, val); 184 /* Set ICB bit */ 185 snd_hdac_chip_updatew(bus, IRS, AZX_IRS_BUSY, AZX_IRS_BUSY); 186 187 ret = snd_hdac_bus_wait_for_pio_response(bus, addr); 188 goto out; 189 } 190 udelay(1); 191 } 192 193 dev_dbg_ratelimited(bus->dev, "send_cmd_pio timeout: IRS=%#x, val=%#x\n", 194 snd_hdac_chip_readw(bus, IRS), val); 195 196 out: 197 spin_unlock_irq(&bus->reg_lock); 198 199 return ret; 200 } 201 202 /** 203 * snd_hdac_bus_get_response_pio - receive a response via Immediate Response 204 * @bus: HD-audio core bus 205 * @addr: codec address 206 * @res: pointer to store the value, NULL when not needed 207 * 208 * Returns zero if a value is read, or a negative error code. 209 */ 210 static int snd_hdac_bus_get_response_pio(struct hdac_bus *bus, 211 unsigned int addr, unsigned int *res) 212 { 213 if (res) 214 *res = bus->rirb.res[addr]; 215 216 return 0; 217 } 218 219 /** 220 * snd_hdac_bus_send_cmd_corb - send a command verb via CORB 221 * @bus: HD-audio core bus 222 * @val: encoded verb value to send 223 * 224 * Returns zero for success or a negative error code. 225 */ 226 static int snd_hdac_bus_send_cmd_corb(struct hdac_bus *bus, unsigned int val) 146 227 { 147 228 unsigned int addr = azx_command_addr(val); … … 177 258 return 0; 178 259 } 179 EXPORT_SYMBOL_GPL(snd_hdac_bus_send_cmd);180 260 181 261 #define AZX_RIRB_EX_UNSOL_EV (1<<4) … … 235 315 236 316 /** 237 * snd_hdac_bus_get_response - receive a response via RIRB317 * snd_hdac_bus_get_response_rirb - receive a response via RIRB 238 318 * @bus: HD-audio core bus 239 319 * @addr: codec address … … 242 322 * Returns zero if a value is read, or a negative error code. 243 323 */ 244 int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr,245 unsigned int *res)324 static int snd_hdac_bus_get_response_rirb(struct hdac_bus *bus, 325 unsigned int addr, unsigned int *res) 246 326 { 247 327 unsigned long timeout; … … 300 380 return -EIO; 301 381 } 382 383 /** 384 * snd_hdac_bus_send_cmd - send a command verb via CORB or PIO 385 * @bus: HD-audio core bus 386 * @val: encoded verb value to send 387 * 388 * Returns zero for success or a negative error code. 389 */ 390 int snd_hdac_bus_send_cmd(struct hdac_bus *bus, unsigned int val) 391 { 392 if (bus->use_pio_for_commands) 393 return snd_hdac_bus_send_cmd_pio(bus, val); 394 395 return snd_hdac_bus_send_cmd_corb(bus, val); 396 } 397 EXPORT_SYMBOL_GPL(snd_hdac_bus_send_cmd); 398 399 /** 400 * snd_hdac_bus_get_response - receive a response via RIRB or PIO 401 * @bus: HD-audio core bus 402 * @addr: codec address 403 * @res: pointer to store the value, NULL when not needed 404 * 405 * Returns zero if a value is read, or a negative error code. 406 */ 407 int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr, 408 unsigned int *res) 409 { 410 if (bus->use_pio_for_commands) 411 return snd_hdac_bus_get_response_pio(bus, addr, res); 412 413 return snd_hdac_bus_get_response_rirb(bus, addr, res); 414 } 302 415 EXPORT_SYMBOL_GPL(snd_hdac_bus_get_response); 303 416
Note:
See TracChangeset
for help on using the changeset viewer.
