Changeset 772 for GPL/trunk/alsa-kernel/hda
- Timestamp:
- Apr 19, 2025, 8:08:37 PM (7 months ago)
- Location:
- GPL/trunk
- Files:
-
- 12 edited
- 2 copied
-
. (modified) (1 prop)
-
alsa-kernel/hda/Makefile (modified) (1 diff)
-
alsa-kernel/hda/ext/hdac_ext_bus.c (modified) (1 diff)
-
alsa-kernel/hda/ext/hdac_ext_controller.c (modified) (16 diffs)
-
alsa-kernel/hda/ext/hdac_ext_stream.c (modified) (17 diffs)
-
alsa-kernel/hda/hdac_bus.c (modified) (1 diff)
-
alsa-kernel/hda/hdac_component.c (copied) (copied from GPL/branches/uniaud32-exp/alsa-kernel/hda/hdac_component.c ) (1 diff)
-
alsa-kernel/hda/hdac_controller.c (modified) (3 diffs)
-
alsa-kernel/hda/hdac_device.c (modified) (3 diffs)
-
alsa-kernel/hda/hdac_i915.c (copied) (copied from GPL/branches/uniaud32-exp/alsa-kernel/hda/hdac_i915.c )
-
alsa-kernel/hda/hdac_regmap.c (modified) (4 diffs)
-
alsa-kernel/hda/hdac_stream.c (modified) (25 diffs)
-
alsa-kernel/hda/hdmi_chmap.c (modified) (3 diffs)
-
alsa-kernel/hda/trace.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-6.6-LTS (added) merged: 765,768-769 /GPL/branches/uniaud32-exp (added) merged: 735-741,743-744,748-751,753-760,762-764 /GPL/branches/uniaud32-next merged: 718-734
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/hda/Makefile
r709 r772 13 13 # 14 14 #=================================================================== 15 FILES = hdac_device.obj array.obj hdac_stream.obj hdac_controller.obj hdac_bus.obj hda_bus_type.obj hdac_regmap.obj hdmi_chmap.obj 15 FILES = hdac_device.obj array.obj hdac_stream.obj hdac_controller.obj hdac_bus.obj hda_bus_type.obj hdac_regmap.obj hdmi_chmap.obj hdac_component.obj 16 # hdac_i915.obj 16 17 17 18 TARGET = hdac -
GPL/trunk/alsa-kernel/hda/ext/hdac_ext_bus.c
r629 r772 60 60 } 61 61 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_exit); 62 63 static void default_release(struct device *dev)64 {65 snd_hdac_ext_bus_device_exit(dev_to_hdac_dev(dev));66 }67 68 /**69 * snd_hdac_ext_bus_device_init - initialize the HDA extended codec base device70 * @bus: hdac bus to attach to71 * @addr: codec address72 * @hdev: hdac device to init73 * @type: codec type (HDAC_DEV_*) to use for this device74 *75 * Returns zero for success or a negative error code.76 */77 int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr,78 struct hdac_device *hdev, int type)79 {80 char name[15];81 int ret;82 83 hdev->bus = bus;84 85 snprintf(name, sizeof(name), "ehdaudio%dD%d", bus->idx, addr);86 87 ret = snd_hdac_device_init(hdev, bus, name, addr);88 if (ret < 0) {89 dev_err(bus->dev, "device init failed for hdac device\n");90 return ret;91 }92 hdev->type = type;93 hdev->dev.release = default_release;94 95 ret = snd_hdac_device_register(hdev);96 if (ret) {97 dev_err(bus->dev, "failed to register hdac device\n");98 snd_hdac_ext_bus_device_exit(hdev);99 return ret;100 }101 102 return 0;103 }104 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_init);105 106 /**107 * snd_hdac_ext_bus_device_exit - clean up a HD-audio extended codec base device108 * @hdev: hdac device to clean up109 */110 void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev)111 {112 snd_hdac_device_exit(hdev);113 }114 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_exit);115 62 116 63 /** -
GPL/trunk/alsa-kernel/hda/ext/hdac_ext_controller.c
r695 r772 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 /* … … 116 109 117 110 /** 118 * snd_hdac_ link_free_all- free hdac extended link objects119 * 120 * @bus: the pointer to HDAC bus object 121 */ 122 123 void snd_hdac_ link_free_all(struct hdac_bus *bus)124 { 125 struct hdac_ext_link * l;111 * snd_hdac_ext_link_free_all- free hdac extended link objects 112 * 113 * @bus: the pointer to HDAC bus object 114 */ 115 116 void snd_hdac_ext_link_free_all(struct hdac_bus *bus) 117 { 118 struct hdac_ext_link *hlink; 126 119 127 120 while (!list_empty(&bus->hlink_list)) { 128 l = list_first_entry(&bus->hlink_list, struct hdac_ext_link, list); 129 list_del(&l->list); 130 kfree(l); 131 } 132 } 133 EXPORT_SYMBOL_GPL(snd_hdac_link_free_all); 134 135 /** 136 * snd_hdac_ext_bus_get_link - get link based on codec name 121 hlink = list_first_entry(&bus->hlink_list, struct hdac_ext_link, list); 122 list_del(&hlink->list); 123 kfree(hlink); 124 } 125 } 126 EXPORT_SYMBOL_GPL(snd_hdac_ext_link_free_all); 127 128 /** 129 * snd_hdac_ext_bus_get_hlink_by_addr - get hlink at specified address 130 * @bus: hlink's parent bus device 131 * @addr: codec device address 132 * 133 * Returns hlink object or NULL if matching hlink is not found. 134 */ 135 struct hdac_ext_link *snd_hdac_ext_bus_get_hlink_by_addr(struct hdac_bus *bus, int addr) 136 { 137 struct hdac_ext_link *hlink; 138 139 list_for_each_entry(hlink, &bus->hlink_list, list) 140 if (hlink->lsdiid & (0x1 << addr)) 141 return hlink; 142 return NULL; 143 } 144 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_get_hlink_by_addr); 145 146 /** 147 * snd_hdac_ext_bus_get_hlink_by_name - get hlink based on codec name 137 148 * @bus: the pointer to HDAC bus object 138 149 * @codec_name: codec name 139 150 */ 140 struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus, 141 const char *codec_name) 142 { 143 int i; 144 struct hdac_ext_link *hlink = NULL; 151 struct hdac_ext_link *snd_hdac_ext_bus_get_hlink_by_name(struct hdac_bus *bus, 152 const char *codec_name) 153 { 145 154 int bus_idx, addr; 146 155 … … 152 161 return NULL; 153 162 154 list_for_each_entry(hlink, &bus->hlink_list, list) { 155 for (i = 0; i < HDA_MAX_CODECS; i++) { 156 if (hlink->lsdiid & (0x1 << addr)) 157 return hlink; 158 } 159 } 160 161 return NULL; 162 } 163 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_get_link); 164 165 static int check_hdac_link_power_active(struct hdac_ext_link *link, bool enable) 163 return snd_hdac_ext_bus_get_hlink_by_addr(bus, addr); 164 } 165 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_get_hlink_by_name); 166 167 static int check_hdac_link_power_active(struct hdac_ext_link *hlink, bool enable) 166 168 { 167 169 int timeout; 168 170 u32 val; 169 int mask = (1 << AZX_ML CTL_CPA_SHIFT);171 int mask = (1 << AZX_ML_LCTL_CPA_SHIFT); 170 172 171 173 udelay(3); … … 173 175 174 176 do { 175 val = readl( link->ml_addr + AZX_REG_ML_LCTL);177 val = readl(hlink->ml_addr + AZX_REG_ML_LCTL); 176 178 if (enable) { 177 if (((val & mask) >> AZX_ML CTL_CPA_SHIFT))179 if (((val & mask) >> AZX_ML_LCTL_CPA_SHIFT)) 178 180 return 0; 179 181 } else { 180 if (!((val & mask) >> AZX_ML CTL_CPA_SHIFT))182 if (!((val & mask) >> AZX_ML_LCTL_CPA_SHIFT)) 181 183 return 0; 182 184 } … … 189 191 /** 190 192 * snd_hdac_ext_bus_link_power_up -power up hda link 191 * @ link: HD-audio extended link192 */ 193 int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link * link)194 { 195 snd_hdac_updatel( link->ml_addr, AZX_REG_ML_LCTL,196 AZX_ML CTL_SPA, AZX_MLCTL_SPA);197 198 return check_hdac_link_power_active( link, true);193 * @hlink: HD-audio extended link 194 */ 195 int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *hlink) 196 { 197 snd_hdac_updatel(hlink->ml_addr, AZX_REG_ML_LCTL, 198 AZX_ML_LCTL_SPA, AZX_ML_LCTL_SPA); 199 200 return check_hdac_link_power_active(hlink, true); 199 201 } 200 202 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_power_up); … … 202 204 /** 203 205 * snd_hdac_ext_bus_link_power_down -power down hda link 204 * @ link: HD-audio extended link205 */ 206 int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link * link)207 { 208 snd_hdac_updatel( link->ml_addr, AZX_REG_ML_LCTL, AZX_MLCTL_SPA, 0);209 210 return check_hdac_link_power_active( link, false);206 * @hlink: HD-audio extended link 207 */ 208 int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *hlink) 209 { 210 snd_hdac_updatel(hlink->ml_addr, AZX_REG_ML_LCTL, AZX_ML_LCTL_SPA, 0); 211 212 return check_hdac_link_power_active(hlink, false); 211 213 } 212 214 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_power_down); … … 222 224 223 225 list_for_each_entry(hlink, &bus->hlink_list, list) { 224 snd_hdac_updatel(hlink->ml_addr, AZX_REG_ML_LCTL, 225 AZX_MLCTL_SPA, AZX_MLCTL_SPA); 226 ret = check_hdac_link_power_active(hlink, true); 226 ret = snd_hdac_ext_bus_link_power_up(hlink); 227 227 if (ret < 0) 228 228 return ret; … … 243 243 244 244 list_for_each_entry(hlink, &bus->hlink_list, list) { 245 snd_hdac_updatel(hlink->ml_addr, AZX_REG_ML_LCTL, 246 AZX_MLCTL_SPA, 0); 247 ret = check_hdac_link_power_active(hlink, false); 245 ret = snd_hdac_ext_bus_link_power_down(hlink); 248 246 if (ret < 0) 249 247 return ret; … … 254 252 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_power_down_all); 255 253 254 /** 255 * snd_hdac_ext_bus_link_set_stream_id - maps stream id to link output 256 * @link: HD-audio ext link to set up 257 * @stream: stream id 258 */ 259 void snd_hdac_ext_bus_link_set_stream_id(struct hdac_ext_link *link, 260 int stream) 261 { 262 snd_hdac_updatew(link->ml_addr, AZX_REG_ML_LOSIDV, (1 << stream), 1 << stream); 263 } 264 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_set_stream_id); 265 266 /** 267 * snd_hdac_ext_bus_link_clear_stream_id - maps stream id to link output 268 * @link: HD-audio ext link to set up 269 * @stream: stream id 270 */ 271 void snd_hdac_ext_bus_link_clear_stream_id(struct hdac_ext_link *link, 272 int stream) 273 { 274 snd_hdac_updatew(link->ml_addr, AZX_REG_ML_LOSIDV, (1 << stream), 0); 275 } 276 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_clear_stream_id); 277 256 278 int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, 257 struct hdac_ext_link * link)279 struct hdac_ext_link *hlink) 258 280 { 259 281 unsigned long codec_mask; … … 266 288 * as well, also check the dma status and trigger that 267 289 */ 268 if (++ link->ref_count == 1) {290 if (++hlink->ref_count == 1) { 269 291 if (!bus->cmd_dma_state) { 270 292 snd_hdac_bus_init_cmd_io(bus); … … 272 294 } 273 295 274 ret = snd_hdac_ext_bus_link_power_up( link);296 ret = snd_hdac_ext_bus_link_power_up(hlink); 275 297 276 298 /* 277 299 * clear the register to invalidate all the output streams 278 300 */ 279 snd_hdac_updatew( link->ml_addr, AZX_REG_ML_LOSIDV,280 ML_LOSIDV_STREAM_MASK, 0);301 snd_hdac_updatew(hlink->ml_addr, AZX_REG_ML_LOSIDV, 302 AZX_ML_LOSIDV_STREAM_MASK, 0); 281 303 /* 282 304 * wait for 521usec for codec to report status … … 297 319 298 320 int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, 299 struct hdac_ext_link *link)321 struct hdac_ext_link *hlink) 300 322 { 301 323 int ret = 0; 302 struct hdac_ext_link *hlink ;324 struct hdac_ext_link *hlink_tmp; 303 325 bool link_up = false; 304 326 … … 309 331 * so power down this link as well 310 332 */ 311 if (-- link->ref_count == 0) {312 ret = snd_hdac_ext_bus_link_power_down( link);333 if (--hlink->ref_count == 0) { 334 ret = snd_hdac_ext_bus_link_power_down(hlink); 313 335 314 336 /* … … 316 338 * cmd dma as well 317 339 */ 318 list_for_each_entry(hlink , &bus->hlink_list, list) {319 if (hlink ->ref_count) {340 list_for_each_entry(hlink_tmp, &bus->hlink_list, list) { 341 if (hlink_tmp->ref_count) { 320 342 link_up = true; 321 343 break; … … 338 360 const char *devname = dev_name(&codec->dev); 339 361 struct hdac_ext_link *hlink = 340 snd_hdac_ext_bus_get_ link(codec->bus, devname);362 snd_hdac_ext_bus_get_hlink_by_name(codec->bus, devname); 341 363 342 364 if (hlink) … … 348 370 const char *devname = dev_name(&codec->dev); 349 371 struct hdac_ext_link *hlink = 350 snd_hdac_ext_bus_get_ link(codec->bus, devname);372 snd_hdac_ext_bus_get_hlink_by_name(codec->bus, devname); 351 373 352 374 if (hlink) -
GPL/trunk/alsa-kernel/hda/ext/hdac_ext_stream.c
r717 r772 15 15 #include <sound/hda_register.h> 16 16 #include <sound/hdaudio_ext.h> 17 #include <sound/compress_driver.h> 17 18 18 19 /** 19 20 * snd_hdac_ext_stream_init - initialize each stream (aka device) 20 21 * @bus: HD-audio core bus 21 * @ stream: HD-audio ext core stream object to initialize22 * @hext_stream: HD-audio ext core stream object to initialize 22 23 * @idx: stream index number 23 24 * @direction: stream direction (SNDRV_PCM_STREAM_PLAYBACK or SNDRV_PCM_STREAM_CAPTURE) … … 27 28 * invoke hdac stream initialization routine 28 29 */ 29 void snd_hdac_ext_stream_init(struct hdac_bus *bus,30 struct hdac_ext_stream *stream,31 int idx, int direction, int tag)30 static void snd_hdac_ext_stream_init(struct hdac_bus *bus, 31 struct hdac_ext_stream *hext_stream, 32 int idx, int direction, int tag) 32 33 { 33 34 if (bus->ppcap) { 34 stream->pphc_addr = bus->ppcap + AZX_PPHC_BASE +35 hext_stream->pphc_addr = bus->ppcap + AZX_PPHC_BASE + 35 36 AZX_PPHC_INTERVAL * idx; 36 37 37 stream->pplc_addr = bus->ppcap + AZX_PPLC_BASE +38 hext_stream->pplc_addr = bus->ppcap + AZX_PPLC_BASE + 38 39 AZX_PPLC_MULTI * bus->num_streams + 39 40 AZX_PPLC_INTERVAL * idx; 40 41 } 41 42 42 if (bus->spbcap) { 43 stream->spib_addr = bus->spbcap + AZX_SPB_BASE + 44 AZX_SPB_INTERVAL * idx + 45 AZX_SPB_SPIB; 46 47 stream->fifo_addr = bus->spbcap + AZX_SPB_BASE + 48 AZX_SPB_INTERVAL * idx + 49 AZX_SPB_MAXFIFO; 50 } 51 52 if (bus->drsmcap) 53 stream->dpibr_addr = bus->drsmcap + AZX_DRSM_BASE + 54 AZX_DRSM_INTERVAL * idx; 55 56 stream->decoupled = false; 57 snd_hdac_stream_init(bus, &stream->hstream, idx, direction, tag); 58 } 59 EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_init); 43 hext_stream->decoupled = false; 44 snd_hdac_stream_init(bus, &hext_stream->hstream, idx, direction, tag); 45 } 60 46 61 47 /** … … 68 54 */ 69 55 int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx, 70 int num_stream, int dir)56 int num_stream, int dir) 71 57 { 72 58 int stream_tag = 0; … … 74 60 75 61 for (i = 0; i < num_stream; i++) { 76 struct hdac_ext_stream * stream =77 kzalloc(sizeof(* stream), GFP_KERNEL);78 if (! stream)62 struct hdac_ext_stream *hext_stream = 63 kzalloc(sizeof(*hext_stream), GFP_KERNEL); 64 if (!hext_stream) 79 65 return -ENOMEM; 80 66 tag = ++stream_tag; 81 snd_hdac_ext_stream_init(bus, stream, idx, dir, tag);67 snd_hdac_ext_stream_init(bus, hext_stream, idx, dir, tag); 82 68 idx++; 83 69 } … … 89 75 90 76 /** 91 * snd_hdac_ stream_free_all - free hdac extended stream objects92 * 93 * @bus: HD-audio core bus 94 */ 95 void snd_hdac_ stream_free_all(struct hdac_bus *bus)77 * snd_hdac_ext_stream_free_all - free hdac extended stream objects 78 * 79 * @bus: HD-audio core bus 80 */ 81 void snd_hdac_ext_stream_free_all(struct hdac_bus *bus) 96 82 { 97 83 struct hdac_stream *s, *_s; 98 struct hdac_ext_stream * stream;84 struct hdac_ext_stream *hext_stream; 99 85 100 86 list_for_each_entry_safe(s, _s, &bus->stream_list, list) { 101 stream = stream_to_hdac_ext_stream(s);102 snd_hdac_ext_stream_decouple(bus, stream, false);87 hext_stream = stream_to_hdac_ext_stream(s); 88 snd_hdac_ext_stream_decouple(bus, hext_stream, false); 103 89 list_del(&s->list); 104 kfree( stream);105 } 106 } 107 EXPORT_SYMBOL_GPL(snd_hdac_ stream_free_all);90 kfree(hext_stream); 91 } 92 } 93 EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_free_all); 108 94 109 95 void snd_hdac_ext_stream_decouple_locked(struct hdac_bus *bus, 110 struct hdac_ext_stream * stream,96 struct hdac_ext_stream *hext_stream, 111 97 bool decouple) 112 98 { 113 struct hdac_stream *hstream = & stream->hstream;99 struct hdac_stream *hstream = &hext_stream->hstream; 114 100 u32 val; 115 101 int mask = AZX_PPCTL_PROCEN(hstream->index); … … 122 108 snd_hdac_updatel(bus->ppcap, AZX_REG_PP_PPCTL, mask, 0); 123 109 124 stream->decoupled = decouple;110 hext_stream->decoupled = decouple; 125 111 } 126 112 EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_decouple_locked); … … 129 115 * snd_hdac_ext_stream_decouple - decouple the hdac stream 130 116 * @bus: HD-audio core bus 131 * @ stream: HD-audio ext core stream object to initialize117 * @hext_stream: HD-audio ext core stream object to initialize 132 118 * @decouple: flag to decouple 133 119 */ 134 120 void snd_hdac_ext_stream_decouple(struct hdac_bus *bus, 135 struct hdac_ext_stream * stream, bool decouple)121 struct hdac_ext_stream *hext_stream, bool decouple) 136 122 { 137 123 spin_lock_irq(&bus->reg_lock); 138 snd_hdac_ext_stream_decouple_locked(bus, stream, decouple);124 snd_hdac_ext_stream_decouple_locked(bus, hext_stream, decouple); 139 125 spin_unlock_irq(&bus->reg_lock); 140 126 } … … 142 128 143 129 /** 144 * snd_hdac_ext_ link_stream_start - start a stream145 * @ stream: HD-audio ext core stream to start146 */ 147 void snd_hdac_ext_ link_stream_start(struct hdac_ext_stream *stream)148 { 149 snd_hdac_updatel( stream->pplc_addr, AZX_REG_PPLCCTL,130 * snd_hdac_ext_stream_start - start a stream 131 * @hext_stream: HD-audio ext core stream to start 132 */ 133 void snd_hdac_ext_stream_start(struct hdac_ext_stream *hext_stream) 134 { 135 snd_hdac_updatel(hext_stream->pplc_addr, AZX_REG_PPLCCTL, 150 136 AZX_PPLCCTL_RUN, AZX_PPLCCTL_RUN); 151 137 } 152 EXPORT_SYMBOL_GPL(snd_hdac_ext_ link_stream_start);153 154 /** 155 * snd_hdac_ext_ link_stream_clear - stop a stream DMA156 * @ stream: HD-audio ext core stream to stop157 */ 158 void snd_hdac_ext_ link_stream_clear(struct hdac_ext_stream *stream)159 { 160 snd_hdac_updatel( stream->pplc_addr, AZX_REG_PPLCCTL, AZX_PPLCCTL_RUN, 0);161 } 162 EXPORT_SYMBOL_GPL(snd_hdac_ext_ link_stream_clear);163 164 /** 165 * snd_hdac_ext_ link_stream_reset - reset a stream166 * @ stream: HD-audio ext core stream to reset167 */ 168 void snd_hdac_ext_ link_stream_reset(struct hdac_ext_stream *stream)138 EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_start); 139 140 /** 141 * snd_hdac_ext_stream_clear - stop a stream DMA 142 * @hext_stream: HD-audio ext core stream to stop 143 */ 144 void snd_hdac_ext_stream_clear(struct hdac_ext_stream *hext_stream) 145 { 146 snd_hdac_updatel(hext_stream->pplc_addr, AZX_REG_PPLCCTL, AZX_PPLCCTL_RUN, 0); 147 } 148 EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_clear); 149 150 /** 151 * snd_hdac_ext_stream_reset - reset a stream 152 * @hext_stream: HD-audio ext core stream to reset 153 */ 154 void snd_hdac_ext_stream_reset(struct hdac_ext_stream *hext_stream) 169 155 { 170 156 unsigned char val; 171 157 int timeout; 172 158 173 snd_hdac_ext_ link_stream_clear(stream);174 175 snd_hdac_updatel( stream->pplc_addr, AZX_REG_PPLCCTL,159 snd_hdac_ext_stream_clear(hext_stream); 160 161 snd_hdac_updatel(hext_stream->pplc_addr, AZX_REG_PPLCCTL, 176 162 AZX_PPLCCTL_STRST, AZX_PPLCCTL_STRST); 177 163 udelay(3); 178 164 timeout = 50; 179 165 do { 180 val = readl( stream->pplc_addr + AZX_REG_PPLCCTL) &166 val = readl(hext_stream->pplc_addr + AZX_REG_PPLCCTL) & 181 167 AZX_PPLCCTL_STRST; 182 168 if (val) … … 185 171 } while (--timeout); 186 172 val &= ~AZX_PPLCCTL_STRST; 187 writel(val, stream->pplc_addr + AZX_REG_PPLCCTL);173 writel(val, hext_stream->pplc_addr + AZX_REG_PPLCCTL); 188 174 udelay(3); 189 175 … … 191 177 /* waiting for hardware to report that the stream is out of reset */ 192 178 do { 193 val = readl( stream->pplc_addr + AZX_REG_PPLCCTL) & AZX_PPLCCTL_STRST;179 val = readl(hext_stream->pplc_addr + AZX_REG_PPLCCTL) & AZX_PPLCCTL_STRST; 194 180 if (!val) 195 181 break; … … 198 184 199 185 } 200 EXPORT_SYMBOL_GPL(snd_hdac_ext_ link_stream_reset);201 202 /** 203 * snd_hdac_ext_ link_stream_setup - set up the SD for streaming204 * @ stream: HD-audio ext core stream to set up186 EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_reset); 187 188 /** 189 * snd_hdac_ext_stream_setup - set up the SD for streaming 190 * @hext_stream: HD-audio ext core stream to set up 205 191 * @fmt: stream format 206 192 */ 207 int snd_hdac_ext_ link_stream_setup(struct hdac_ext_stream *stream, int fmt)208 { 209 struct hdac_stream *hstream = & stream->hstream;193 int snd_hdac_ext_stream_setup(struct hdac_ext_stream *hext_stream, int fmt) 194 { 195 struct hdac_stream *hstream = &hext_stream->hstream; 210 196 unsigned int val; 211 197 212 198 /* make sure the run bit is zero for SD */ 213 snd_hdac_ext_ link_stream_clear(stream);199 snd_hdac_ext_stream_clear(hext_stream); 214 200 /* program the stream_tag */ 215 val = readl( stream->pplc_addr + AZX_REG_PPLCCTL);201 val = readl(hext_stream->pplc_addr + AZX_REG_PPLCCTL); 216 202 val = (val & ~AZX_PPLCCTL_STRM_MASK) | 217 203 (hstream->stream_tag << AZX_PPLCCTL_STRM_SHIFT); 218 writel(val, stream->pplc_addr + AZX_REG_PPLCCTL);204 writel(val, hext_stream->pplc_addr + AZX_REG_PPLCCTL); 219 205 220 206 /* program the stream format */ 221 writew(fmt, stream->pplc_addr + AZX_REG_PPLCFMT);207 writew(fmt, hext_stream->pplc_addr + AZX_REG_PPLCFMT); 222 208 223 209 return 0; 224 210 } 225 EXPORT_SYMBOL_GPL(snd_hdac_ext_link_stream_setup); 226 227 /** 228 * snd_hdac_ext_link_set_stream_id - maps stream id to link output 229 * @link: HD-audio ext link to set up 230 * @stream: stream id 231 */ 232 void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link, 233 int stream) 234 { 235 snd_hdac_updatew(link->ml_addr, AZX_REG_ML_LOSIDV, (1 << stream), 1 << stream); 236 } 237 EXPORT_SYMBOL_GPL(snd_hdac_ext_link_set_stream_id); 238 239 /** 240 * snd_hdac_ext_link_clear_stream_id - maps stream id to link output 241 * @link: HD-audio ext link to set up 242 * @stream: stream id 243 */ 244 void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link, 245 int stream) 246 { 247 snd_hdac_updatew(link->ml_addr, AZX_REG_ML_LOSIDV, (1 << stream), 0); 248 } 249 EXPORT_SYMBOL_GPL(snd_hdac_ext_link_clear_stream_id); 211 EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_setup); 250 212 251 213 static struct hdac_ext_stream * 252 hdac_ext_link_ stream_assign(struct hdac_bus *bus,214 hdac_ext_link_dma_stream_assign(struct hdac_bus *bus, 253 215 struct snd_pcm_substream *substream) 254 216 { 255 217 struct hdac_ext_stream *res = NULL; 256 struct hdac_stream * stream = NULL;218 struct hdac_stream *hstream = NULL; 257 219 258 220 if (!bus->ppcap) { … … 262 224 263 225 spin_lock_irq(&bus->reg_lock); 264 list_for_each_entry( stream, &bus->stream_list, list) {265 struct hdac_ext_stream *h stream = container_of(stream,266 struct hdac_ext_stream,267 hstream);268 if ( stream->direction != substream->stream)226 list_for_each_entry(hstream, &bus->stream_list, list) { 227 struct hdac_ext_stream *hext_stream = container_of(hstream, 228 struct hdac_ext_stream, 229 hstream); 230 if (hstream->direction != substream->stream) 269 231 continue; 270 232 271 /* check if decoupled stream and not in useis available */272 if ( hstream->decoupled && !hstream->link_locked) {273 res = h stream;233 /* check if link stream is available */ 234 if (!hext_stream->link_locked) { 235 res = hext_stream; 274 236 break; 275 237 } 276 238 277 if (!hstream->link_locked) {278 snd_hdac_ext_stream_decouple_locked(bus, hstream, true);279 res = hstream;280 break;281 }282 239 } 283 240 if (res) { 241 snd_hdac_ext_stream_decouple_locked(bus, res, true); 284 242 res->link_locked = 1; 285 243 res->link_substream = substream; … … 290 248 291 249 static struct hdac_ext_stream * 292 hdac_ext_host_ stream_assign(struct hdac_bus *bus,250 hdac_ext_host_dma_stream_assign(struct hdac_bus *bus, 293 251 struct snd_pcm_substream *substream) 294 252 { 295 253 struct hdac_ext_stream *res = NULL; 296 struct hdac_stream * stream = NULL;254 struct hdac_stream *hstream = NULL; 297 255 298 256 if (!bus->ppcap) { … … 302 260 303 261 spin_lock_irq(&bus->reg_lock); 304 list_for_each_entry( stream, &bus->stream_list, list) {305 struct hdac_ext_stream *h stream = container_of(stream,306 struct hdac_ext_stream,307 hstream);308 if ( stream->direction != substream->stream)262 list_for_each_entry(hstream, &bus->stream_list, list) { 263 struct hdac_ext_stream *hext_stream = container_of(hstream, 264 struct hdac_ext_stream, 265 hstream); 266 if (hstream->direction != substream->stream) 309 267 continue; 310 268 311 if (!stream->opened) { 312 if (!hstream->decoupled) 313 snd_hdac_ext_stream_decouple_locked(bus, hstream, true); 314 res = hstream; 269 if (!hstream->opened) { 270 res = hext_stream; 315 271 break; 316 272 } 317 273 } 318 274 if (res) { 275 snd_hdac_ext_stream_decouple_locked(bus, res, true); 319 276 res->hstream.opened = 1; 320 277 res->hstream.running = 0; … … 347 304 int type) 348 305 { 349 struct hdac_ext_stream *h stream = NULL;350 struct hdac_stream * stream = NULL;306 struct hdac_ext_stream *hext_stream = NULL; 307 struct hdac_stream *hstream = NULL; 351 308 352 309 switch (type) { 353 310 case HDAC_EXT_STREAM_TYPE_COUPLED: 354 stream = snd_hdac_stream_assign(bus, substream); 355 if (stream) 356 hstream = container_of(stream, 357 struct hdac_ext_stream, hstream); 358 return hstream; 311 hstream = snd_hdac_stream_assign(bus, substream); 312 if (hstream) 313 hext_stream = container_of(hstream, 314 struct hdac_ext_stream, 315 hstream); 316 return hext_stream; 359 317 360 318 case HDAC_EXT_STREAM_TYPE_HOST: 361 return hdac_ext_host_ stream_assign(bus, substream);319 return hdac_ext_host_dma_stream_assign(bus, substream); 362 320 363 321 case HDAC_EXT_STREAM_TYPE_LINK: 364 return hdac_ext_link_ stream_assign(bus, substream);322 return hdac_ext_link_dma_stream_assign(bus, substream); 365 323 366 324 default: … … 372 330 /** 373 331 * snd_hdac_ext_stream_release - release the assigned stream 374 * @ stream: HD-audio ext core stream to release332 * @hext_stream: HD-audio ext core stream to release 375 333 * @type: type of stream (coupled, host or link stream) 376 334 * 377 335 * Release the stream that has been assigned by snd_hdac_ext_stream_assign(). 378 336 */ 379 void snd_hdac_ext_stream_release(struct hdac_ext_stream * stream, int type)380 { 381 struct hdac_bus *bus = stream->hstream.bus;337 void snd_hdac_ext_stream_release(struct hdac_ext_stream *hext_stream, int type) 338 { 339 struct hdac_bus *bus = hext_stream->hstream.bus; 382 340 383 341 switch (type) { 384 342 case HDAC_EXT_STREAM_TYPE_COUPLED: 385 snd_hdac_stream_release(& stream->hstream);343 snd_hdac_stream_release(&hext_stream->hstream); 386 344 break; 387 345 388 346 case HDAC_EXT_STREAM_TYPE_HOST: 389 347 spin_lock_irq(&bus->reg_lock); 390 if (stream->decoupled && !stream->link_locked) 391 snd_hdac_ext_stream_decouple_locked(bus, stream, false); 348 /* couple link only if not in use */ 349 if (!hext_stream->link_locked) 350 snd_hdac_ext_stream_decouple_locked(bus, hext_stream, false); 351 snd_hdac_stream_release_locked(&hext_stream->hstream); 392 352 spin_unlock_irq(&bus->reg_lock); 393 snd_hdac_stream_release(&stream->hstream);394 353 break; 395 354 396 355 case HDAC_EXT_STREAM_TYPE_LINK: 397 356 spin_lock_irq(&bus->reg_lock); 398 if (stream->decoupled && !stream->hstream.opened) 399 snd_hdac_ext_stream_decouple_locked(bus, stream, false); 400 stream->link_locked = 0; 401 stream->link_substream = NULL; 357 /* couple host only if not in use */ 358 if (!hext_stream->hstream.opened) 359 snd_hdac_ext_stream_decouple_locked(bus, hext_stream, false); 360 hext_stream->link_locked = 0; 361 hext_stream->link_substream = NULL; 402 362 spin_unlock_irq(&bus->reg_lock); 403 363 break; … … 411 371 412 372 /** 413 * snd_hdac_ext_stream_spbcap_enable - enable SPIB for a stream 414 * @bus: HD-audio core bus 415 * @enable: flag to enable/disable SPIB 416 * @index: stream index for which SPIB need to be enabled 417 */ 418 void snd_hdac_ext_stream_spbcap_enable(struct hdac_bus *bus, 419 bool enable, int index) 420 { 421 u32 mask = 0; 422 423 if (!bus->spbcap) { 424 dev_err(bus->dev, "Address of SPB capability is NULL\n"); 425 return; 426 } 427 428 mask |= (1 << index); 429 430 if (enable) 431 snd_hdac_updatel(bus->spbcap, AZX_REG_SPB_SPBFCCTL, mask, mask); 432 else 433 snd_hdac_updatel(bus->spbcap, AZX_REG_SPB_SPBFCCTL, mask, 0); 434 } 435 EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_spbcap_enable); 436 437 /** 438 * snd_hdac_ext_stream_set_spib - sets the spib value of a stream 439 * @bus: HD-audio core bus 440 * @stream: hdac_ext_stream 441 * @value: spib value to set 442 */ 443 int snd_hdac_ext_stream_set_spib(struct hdac_bus *bus, 444 struct hdac_ext_stream *stream, u32 value) 445 { 446 447 if (!bus->spbcap) { 448 dev_err(bus->dev, "Address of SPB capability is NULL\n"); 449 return -EINVAL; 450 } 451 452 writel(value, stream->spib_addr); 453 454 return 0; 455 } 456 EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_set_spib); 457 458 /** 459 * snd_hdac_ext_stream_get_spbmaxfifo - gets the spib value of a stream 460 * @bus: HD-audio core bus 461 * @stream: hdac_ext_stream 462 * 463 * Return maxfifo for the stream 464 */ 465 int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_bus *bus, 466 struct hdac_ext_stream *stream) 467 { 468 469 if (!bus->spbcap) { 470 dev_err(bus->dev, "Address of SPB capability is NULL\n"); 471 return -EINVAL; 472 } 473 474 return readl(stream->fifo_addr); 475 } 476 EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_get_spbmaxfifo); 477 478 479 /** 480 * snd_hdac_ext_stop_streams - stop all stream if running 481 * @bus: HD-audio core bus 482 */ 483 void snd_hdac_ext_stop_streams(struct hdac_bus *bus) 484 { 485 struct hdac_stream *stream; 486 487 if (bus->chip_init) { 488 list_for_each_entry(stream, &bus->stream_list, list) 489 snd_hdac_stream_stop(stream); 490 snd_hdac_bus_stop_chip(bus); 491 } 492 } 493 EXPORT_SYMBOL_GPL(snd_hdac_ext_stop_streams); 494 495 /** 496 * snd_hdac_ext_stream_drsm_enable - enable DMA resume for a stream 497 * @bus: HD-audio core bus 498 * @enable: flag to enable/disable DRSM 499 * @index: stream index for which DRSM need to be enabled 500 */ 501 void snd_hdac_ext_stream_drsm_enable(struct hdac_bus *bus, 502 bool enable, int index) 503 { 504 u32 mask = 0; 505 506 if (!bus->drsmcap) { 507 dev_err(bus->dev, "Address of DRSM capability is NULL\n"); 508 return; 509 } 510 511 mask |= (1 << index); 512 513 if (enable) 514 snd_hdac_updatel(bus->drsmcap, AZX_REG_DRSM_CTL, mask, mask); 515 else 516 snd_hdac_updatel(bus->drsmcap, AZX_REG_DRSM_CTL, mask, 0); 517 } 518 EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_drsm_enable); 519 520 /** 521 * snd_hdac_ext_stream_set_dpibr - sets the dpibr value of a stream 522 * @bus: HD-audio core bus 523 * @stream: hdac_ext_stream 524 * @value: dpib value to set 525 */ 526 int snd_hdac_ext_stream_set_dpibr(struct hdac_bus *bus, 527 struct hdac_ext_stream *stream, u32 value) 528 { 529 530 if (!bus->drsmcap) { 531 dev_err(bus->dev, "Address of DRSM capability is NULL\n"); 532 return -EINVAL; 533 } 534 535 writel(value, stream->dpibr_addr); 536 537 return 0; 538 } 539 EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_set_dpibr); 540 541 /** 542 * snd_hdac_ext_stream_set_lpib - sets the lpib value of a stream 543 * @stream: hdac_ext_stream 544 * @value: lpib value to set 545 */ 546 int snd_hdac_ext_stream_set_lpib(struct hdac_ext_stream *stream, u32 value) 547 { 548 snd_hdac_stream_writel(&stream->hstream, SD_LPIB, value); 549 550 return 0; 551 } 552 EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_set_lpib); 373 * snd_hdac_ext_cstream_assign - assign a host stream for compress 374 * @bus: HD-audio core bus 375 * @cstream: Compress stream to assign 376 * 377 * Assign an unused host stream for the given compress stream. 378 * If no stream is free, NULL is returned. Stream is decoupled 379 * before assignment. 380 */ 381 struct hdac_ext_stream *snd_hdac_ext_cstream_assign(struct hdac_bus *bus, 382 struct snd_compr_stream *cstream) 383 { 384 struct hdac_ext_stream *res = NULL; 385 struct hdac_stream *hstream; 386 387 spin_lock_irq(&bus->reg_lock); 388 list_for_each_entry(hstream, &bus->stream_list, list) { 389 struct hdac_ext_stream *hext_stream = stream_to_hdac_ext_stream(hstream); 390 391 if (hstream->direction != cstream->direction) 392 continue; 393 394 if (!hstream->opened) { 395 res = hext_stream; 396 break; 397 } 398 } 399 400 if (res) { 401 snd_hdac_ext_stream_decouple_locked(bus, res, true); 402 res->hstream.opened = 1; 403 res->hstream.running = 0; 404 res->hstream.cstream = cstream; 405 } 406 spin_unlock_irq(&bus->reg_lock); 407 408 return res; 409 } 410 EXPORT_SYMBOL_GPL(snd_hdac_ext_cstream_assign); -
GPL/trunk/alsa-kernel/hda/hdac_bus.c
r695 r772 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/trunk/alsa-kernel/hda/hdac_component.c
r764 r772 194 194 return ret; 195 195 196 #ifndef TARGET_OS2 196 197 if (WARN_ON(!(acomp->dev && acomp->ops))) { 197 198 ret = -EINVAL; 198 199 goto out_unbind; 199 200 } 201 #endif 200 202 201 203 /* pin the module to avoid dynamic unbinding, but only if given */ -
GPL/trunk/alsa-kernel/hda/hdac_controller.c
r717 r772 80 80 snd_hdac_chip_writew(bus, RINTCNT, 1); 81 81 /* enable rirb dma and response irq */ 82 snd_hdac_chip_writeb(bus, RIRBCTL, AZX_RBCTL_DMA_EN | AZX_RBCTL_IRQ_EN); 82 if (bus->not_use_interrupts) 83 snd_hdac_chip_writeb(bus, RIRBCTL, AZX_RBCTL_DMA_EN); 84 else 85 snd_hdac_chip_writeb(bus, RIRBCTL, AZX_RBCTL_DMA_EN | AZX_RBCTL_IRQ_EN); 83 86 /* Accept unsolicited responses */ 84 87 snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_UNSOL, AZX_GCTL_UNSOL); … … 481 484 snd_hdac_stream_updateb(azx_dev, SD_CTL, SD_INT_MASK, 0); 482 485 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); 486 /* disable SIE for all streams & disable controller CIE and GIE */ 487 snd_hdac_chip_writel(bus, INTCTL, 0); 488 488 } 489 489 … … 588 588 snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK); 589 589 handled |= 1 << azx_dev->index; 590 if ( !azx_dev->substream || !azx_dev->running||591 ! (sd_status & SD_INT_COMPLETE))590 if ((!azx_dev->substream && !azx_dev->cstream) || 591 !azx_dev->running || !(sd_status & SD_INT_COMPLETE)) 592 592 continue; 593 593 if (ack) -
GPL/trunk/alsa-kernel/hda/hdac_device.c
r717 r772 212 212 * Returns the size of string, like snprintf(), or a negative error code. 213 213 */ 214 int snd_hdac_codec_modalias( struct hdac_device *codec, char *buf, size_t size)214 int snd_hdac_codec_modalias(const struct hdac_device *codec, char *buf, size_t size) 215 215 { 216 216 return scnprintf(buf, size, "hdaudio:v%08Xr%08Xa%02X\n", … … 623 623 #if 0 //fixme 624 624 if (!atomic_inc_not_zero(&codec->in_pm)) { 625 int ret = pm_runtime_get_if_ in_use(&codec->dev);625 int ret = pm_runtime_get_if_active(&codec->dev, true); 626 626 if (!ret) 627 627 return -1; … … 660 660 661 661 static const struct hda_vendor_id hda_vendor_ids[] = { 662 { 0x0014, "Loongson" }, 662 663 { 0x1002, "ATI" }, 663 664 { 0x1013, "Cirrus Logic" }, -
GPL/trunk/alsa-kernel/hda/hdac_regmap.c
r695 r772 18 18 #include <linux/export.h> 19 19 #include <linux/pm.h> 20 #include <linux/pm_runtime.h>21 20 #include <sound/core.h> 22 21 #include <sound/hdaudio.h> … … 359 358 .readable_reg = hda_readable_reg, 360 359 .volatile_reg = hda_volatile_reg, 360 #ifndef TARGET_OS2 361 .cache_type = REGCACHE_MAPLE, 362 #else 361 363 .cache_type = REGCACHE_RBTREE, 364 #endif 362 365 .reg_read = hda_reg_read, 363 366 .reg_write = hda_reg_write, … … 570 573 unsigned int mask, unsigned int val) 571 574 { 575 #ifndef TARGET_OS2 576 int err = 0; 577 #else 572 578 unsigned int orig; 573 579 int err; 574 580 #endif 575 581 if (!codec->regmap) 576 582 return reg_raw_update(codec, reg, mask, val); 577 583 578 584 mutex_lock(&codec->regmap_lock); 585 #ifndef TARGET_OS2 586 /* Discard any updates to already initialised registers. */ 587 if (!regcache_reg_cached(codec->regmap, reg)) 588 #else 579 589 regcache_cache_only(codec->regmap, true); 580 590 err = regmap_read(codec->regmap, reg, &orig); 581 591 regcache_cache_only(codec->regmap, false); 582 592 if (err < 0) 593 #endif 583 594 err = regmap_update_bits(codec->regmap, reg, mask, val); 584 595 mutex_unlock(&codec->regmap_lock); … … 614 625 void snd_hdac_regmap_sync(struct hdac_device *codec) 615 626 { 616 if (codec->regmap) {617 mutex_lock(&codec->regmap_lock);627 mutex_lock(&codec->regmap_lock); 628 if (codec->regmap) 618 629 regcache_sync(codec->regmap); 619 mutex_unlock(&codec->regmap_lock); 620 } 630 mutex_unlock(&codec->regmap_lock); 621 631 } 622 632 EXPORT_SYMBOL_GPL(snd_hdac_regmap_sync); -
GPL/trunk/alsa-kernel/hda/hdac_stream.c
r717 r772 8 8 #include <linux/export.h> 9 9 #include <linux/clocksource.h> 10 #include <sound/compress_driver.h> 10 11 #include <sound/core.h> 11 12 #include <sound/pcm.h> … … 19 20 #endif 20 21 22 /* 23 * the hdac_stream library is intended to be used with the following 24 * transitions. The states are not formally defined in the code but loosely 25 * inspired by boolean variables. Note that the 'prepared' field is not used 26 * in this library but by the callers during the hw_params/prepare transitions 27 * 28 * | 29 * stream_init() | 30 * v 31 * +--+-------+ 32 * | unused | 33 * +--+----+--+ 34 * | ^ 35 * stream_assign() | | stream_release() 36 * v | 37 * +--+----+--+ 38 * | opened | 39 * +--+----+--+ 40 * | ^ 41 * stream_reset() | | 42 * stream_setup() | | stream_cleanup() 43 * v | 44 * +--+----+--+ 45 * | prepared | 46 * +--+----+--+ 47 * | ^ 48 * stream_start() | | stream_stop() 49 * v | 50 * +--+----+--+ 51 * | running | 52 * +----------+ 53 */ 54 21 55 /** 22 56 * snd_hdac_get_stream_stripe_ctl - get stripe control value … … 76 110 snd_hdac_dsp_lock_init(azx_dev); 77 111 list_add_tail(&azx_dev->list, &bus->stream_list); 112 113 if (bus->spbcap) { 114 azx_dev->spib_addr = (void*)bus->spbcap + AZX_SPB_BASE + 115 AZX_SPB_INTERVAL * idx + 116 AZX_SPB_SPIB; 117 118 azx_dev->fifo_addr = (void*)bus->spbcap + AZX_SPB_BASE + 119 AZX_SPB_INTERVAL * idx + 120 AZX_SPB_MAXFIFO; 121 } 122 123 if (bus->drsmcap) 124 azx_dev->dpibr_addr = (void*)bus->drsmcap + AZX_DRSM_BASE + 125 AZX_DRSM_INTERVAL * idx; 78 126 } 79 127 EXPORT_SYMBOL_GPL(snd_hdac_stream_init); … … 82 130 * snd_hdac_stream_start - start a stream 83 131 * @azx_dev: HD-audio core stream to start 84 * @fresh_start: false = wallclock timestamp relative to period wallclock85 132 * 86 133 * Start a stream, set start_wallclk and set the running flag. 87 134 */ 88 void snd_hdac_stream_start(struct hdac_stream *azx_dev , bool fresh_start)135 void snd_hdac_stream_start(struct hdac_stream *azx_dev) 89 136 { 90 137 struct hdac_bus *bus = azx_dev->bus; … … 94 141 95 142 azx_dev->start_wallclk = snd_hdac_chip_readl(bus, WALLCLK); 96 if (!fresh_start)97 azx_dev->start_wallclk -= azx_dev->period_wallclk;98 143 99 144 /* enable SIE */ … … 111 156 } 112 157 /* set DMA start and interrupt mask */ 113 snd_hdac_stream_updateb(azx_dev, SD_CTL, 158 if (bus->access_sdnctl_in_dword) 159 snd_hdac_stream_updatel(azx_dev, SD_CTL, 160 0, SD_CTL_DMA_START | SD_INT_MASK); 161 else 162 snd_hdac_stream_updateb(azx_dev, SD_CTL, 114 163 0, SD_CTL_DMA_START | SD_INT_MASK); 115 164 azx_dev->running = true; … … 118 167 119 168 /** 120 * snd_hdac_stream_clear - stop a stream DMA169 * snd_hdac_stream_clear - helper to clear stream registers and stop DMA transfers 121 170 * @azx_dev: HD-audio core stream to stop 122 171 */ 123 void snd_hdac_stream_clear(struct hdac_stream *azx_dev)172 static void snd_hdac_stream_clear(struct hdac_stream *azx_dev) 124 173 { 125 174 snd_hdac_stream_updateb(azx_dev, SD_CTL, … … 130 179 azx_dev->running = false; 131 180 } 132 EXPORT_SYMBOL_GPL(snd_hdac_stream_clear);133 181 134 182 /** … … 149 197 150 198 /** 199 * snd_hdac_stop_streams - stop all streams 200 * @bus: HD-audio core bus 201 */ 202 void snd_hdac_stop_streams(struct hdac_bus *bus) 203 { 204 struct hdac_stream *stream; 205 206 list_for_each_entry(stream, &bus->stream_list, list, struct hdac_stream) 207 snd_hdac_stream_stop(stream); 208 } 209 EXPORT_SYMBOL_GPL(snd_hdac_stop_streams); 210 211 /** 212 * snd_hdac_stop_streams_and_chip - stop all streams and chip if running 213 * @bus: HD-audio core bus 214 */ 215 void snd_hdac_stop_streams_and_chip(struct hdac_bus *bus) 216 { 217 if (bus->chip_init) { 218 snd_hdac_stop_streams(bus); 219 snd_hdac_bus_stop_chip(bus); 220 } 221 } 222 EXPORT_SYMBOL_GPL(snd_hdac_stop_streams_and_chip); 223 224 /** 151 225 * snd_hdac_stream_reset - reset a stream 152 226 * @azx_dev: HD-audio core stream to reset … … 155 229 { 156 230 unsigned char val; 231 #ifdef TARGET_OS2 157 232 int timeout; 233 #endif 158 234 int dma_run_state; 159 235 … … 163 239 164 240 snd_hdac_stream_updateb(azx_dev, SD_CTL, 0, SD_CTL_STREAM_RESET); 241 242 #ifndef TARGET_OS2 243 /* wait for hardware to report that the stream entered reset */ 244 snd_hdac_stream_readb_poll(azx_dev, SD_CTL, val, (val & SD_CTL_STREAM_RESET), 3, 300); 245 #else 165 246 udelay(3); 166 247 timeout = 300; … … 171 252 break; 172 253 } while (--timeout); 173 254 #endif 174 255 if (azx_dev->bus->dma_stop_delay && dma_run_state) 175 256 udelay(azx_dev->bus->dma_stop_delay); 176 257 177 val &= ~SD_CTL_STREAM_RESET; 178 snd_hdac_stream_writeb(azx_dev, SD_CTL, val); 258 snd_hdac_stream_updateb(azx_dev, SD_CTL, SD_CTL_STREAM_RESET, 0); 259 260 #ifndef TARGET_OS2 261 /* wait for hardware to report that the stream is out of reset */ 262 snd_hdac_stream_readb_poll(azx_dev, SD_CTL, val, !(val & SD_CTL_STREAM_RESET), 3, 300); 263 #else 179 264 udelay(3); 180 265 … … 187 272 break; 188 273 } while (--timeout); 189 274 #endif 190 275 /* reset first position - may not be synced with hw at this time */ 191 276 if (azx_dev->posbuf) … … 299 384 300 385 /* make a non-zero unique key for the substream */ 301 int key = (substream->pcm->device << 16) | (substream->number << 2) | 302 (substream->stream + 1); 386 int key = (substream->number << 2) | (substream->stream + 1); 387 388 if (substream->pcm) 389 key |= (substream->pcm->device << 16); 303 390 304 391 spin_lock_irq(&bus->reg_lock); … … 327 414 328 415 /** 329 * snd_hdac_stream_release - release the assigned stream416 * snd_hdac_stream_release_locked - release the assigned stream 330 417 * @azx_dev: HD-audio core stream to release 331 418 * 332 419 * Release the stream that has been assigned by snd_hdac_stream_assign(). 333 */ 334 void snd_hdac_stream_release(struct hdac_stream *azx_dev) 335 { 336 struct hdac_bus *bus = azx_dev->bus; 337 338 spin_lock_irq(&bus->reg_lock); 420 * The bus->reg_lock needs to be taken at a higher level 421 */ 422 void snd_hdac_stream_release_locked(struct hdac_stream *azx_dev) 423 { 339 424 azx_dev->opened = 0; 340 425 azx_dev->running = 0; 341 426 azx_dev->substream = NULL; 427 } 428 EXPORT_SYMBOL_GPL(snd_hdac_stream_release_locked); 429 430 /** 431 * snd_hdac_stream_release - release the assigned stream 432 * @azx_dev: HD-audio core stream to release 433 * 434 * Release the stream that has been assigned by snd_hdac_stream_assign(). 435 */ 436 void snd_hdac_stream_release(struct hdac_stream *azx_dev) 437 { 438 struct hdac_bus *bus = azx_dev->bus; 439 440 spin_lock_irq(&bus->reg_lock); 441 snd_hdac_stream_release_locked(azx_dev); 342 442 spin_unlock_irq(&bus->reg_lock); 343 443 } … … 421 521 struct hdac_bus *bus = azx_dev->bus; 422 522 struct snd_pcm_substream *substream = azx_dev->substream; 423 struct snd_pcm_runtime *runtime = substream->runtime; 523 struct snd_compr_stream *cstream = azx_dev->cstream; 524 struct snd_pcm_runtime *runtime = NULL; 525 struct snd_dma_buffer *dmab; 424 526 __le32 *bdl; 425 527 int i, ofs, periods, period_bytes; 426 528 int pos_adj, pos_align; 529 530 if (substream) { 531 runtime = substream->runtime; 532 dmab = snd_pcm_get_dma_buf(substream); 533 } else if (cstream) { 534 dmab = snd_pcm_get_dma_buf(cstream); 535 } else { 536 WARN(1, "No substream or cstream assigned\n"); 537 return -EINVAL; 538 } 427 539 428 540 /* reset BDL address */ … … 439 551 440 552 pos_adj = bus->bdl_pos_adj; 441 if ( !azx_dev->no_period_wakeup && pos_adj > 0) {553 if (runtime && !azx_dev->no_period_wakeup && pos_adj > 0) { 442 554 pos_align = pos_adj; 443 555 pos_adj = DIV_ROUND_UP(pos_adj * runtime->rate, 48000); … … 452 564 pos_adj = 0; 453 565 } else { 454 ofs = setup_bdle(bus, snd_pcm_get_dma_buf(substream), 455 azx_dev, 566 ofs = setup_bdle(bus, dmab, azx_dev, 456 567 &bdl, ofs, pos_adj, true); 457 568 if (ofs < 0) … … 463 574 for (i = 0; i < periods; i++) { 464 575 if (i == periods - 1 && pos_adj) 465 ofs = setup_bdle(bus, snd_pcm_get_dma_buf(substream), 466 azx_dev, &bdl, ofs, 467 period_bytes - pos_adj, 0); 576 ofs = setup_bdle(bus, dmab, azx_dev, 577 &bdl, ofs, period_bytes - pos_adj, 0); 468 578 else 469 ofs = setup_bdle(bus, snd_pcm_get_dma_buf(substream), 470 azx_dev, &bdl, ofs, 471 period_bytes, 579 ofs = setup_bdle(bus, dmab, azx_dev, 580 &bdl, ofs, period_bytes, 472 581 !azx_dev->no_period_wakeup); 473 582 if (ofs < 0) … … 494 603 unsigned int format_val) 495 604 { 496 605 struct snd_pcm_substream *substream = azx_dev->substream; 606 struct snd_compr_stream *cstream = azx_dev->cstream; 497 607 unsigned int bufsize, period_bytes; 498 struct snd_pcm_substream *substream = azx_dev->substream; 499 struct snd_pcm_runtime *runtime; 608 unsigned int no_period_wakeup; 500 609 int err; 501 610 502 if (!substream) 611 if (substream) { 612 bufsize = snd_pcm_lib_buffer_bytes(substream); 613 period_bytes = snd_pcm_lib_period_bytes(substream); 614 no_period_wakeup = substream->runtime->no_period_wakeup; 615 } else if (cstream) { 616 bufsize = cstream->runtime->buffer_size; 617 period_bytes = cstream->runtime->fragment_size; 618 no_period_wakeup = 0; 619 } else { 503 620 return -EINVAL; 504 runtime = substream->runtime; 505 bufsize = snd_pcm_lib_buffer_bytes(substream); 506 period_bytes = snd_pcm_lib_period_bytes(substream); 621 } 507 622 508 623 if (bufsize != azx_dev->bufsize || 509 624 period_bytes != azx_dev->period_bytes || 510 625 format_val != azx_dev->format_val || 511 runtime->no_period_wakeup != azx_dev->no_period_wakeup) {626 no_period_wakeup != azx_dev->no_period_wakeup) { 512 627 azx_dev->bufsize = bufsize; 513 628 azx_dev->period_bytes = period_bytes; 514 629 azx_dev->format_val = format_val; 515 azx_dev->no_period_wakeup = runtime->no_period_wakeup;630 azx_dev->no_period_wakeup = no_period_wakeup; 516 631 err = snd_hdac_stream_setup_periods(azx_dev); 517 632 if (err < 0) … … 589 704 bool inited = false; 590 705 u64 cycle_last = 0; 591 int i = 0;592 706 593 707 list_for_each_entry(s, &bus->stream_list, list, struct hdac_stream) { 594 if ( streams & (1 << i)) {708 if ((streams & (1 << s->index))) { 595 709 azx_timecounter_init(s, inited, cycle_last); 596 710 if (!inited) { … … 599 713 } 600 714 } 601 i++;602 715 } 603 716 … … 644 757 { 645 758 struct hdac_bus *bus = azx_dev->bus; 646 int i,nwait, timeout;759 int nwait, timeout; 647 760 struct hdac_stream *s; 648 761 649 762 for (timeout = 5000; timeout; timeout--) { 650 763 nwait = 0; 651 i = 0;652 764 list_for_each_entry(s, &bus->stream_list, list, struct hdac_stream) { 653 if (!(streams & (1 << i++)))765 if (!(streams & (1 << s->index))) 654 766 continue; 655 767 … … 680 792 EXPORT_SYMBOL_GPL(snd_hdac_stream_sync); 681 793 794 /** 795 * snd_hdac_stream_spbcap_enable - enable SPIB for a stream 796 * @bus: HD-audio core bus 797 * @enable: flag to enable/disable SPIB 798 * @index: stream index for which SPIB need to be enabled 799 */ 800 void snd_hdac_stream_spbcap_enable(struct hdac_bus *bus, 801 bool enable, int index) 802 { 803 u32 mask = 0; 804 805 if (!bus->spbcap) { 806 dev_err(bus->dev, "Address of SPB capability is NULL\n"); 807 return; 808 } 809 810 mask |= (1 << index); 811 812 if (enable) 813 snd_hdac_updatel(bus->spbcap, AZX_REG_SPB_SPBFCCTL, mask, mask); 814 else 815 snd_hdac_updatel(bus->spbcap, AZX_REG_SPB_SPBFCCTL, mask, 0); 816 } 817 EXPORT_SYMBOL_GPL(snd_hdac_stream_spbcap_enable); 818 819 /** 820 * snd_hdac_stream_set_spib - sets the spib value of a stream 821 * @bus: HD-audio core bus 822 * @azx_dev: hdac_stream 823 * @value: spib value to set 824 */ 825 int snd_hdac_stream_set_spib(struct hdac_bus *bus, 826 struct hdac_stream *azx_dev, u32 value) 827 { 828 if (!bus->spbcap) { 829 dev_err(bus->dev, "Address of SPB capability is NULL\n"); 830 return -EINVAL; 831 } 832 833 writel(value, azx_dev->spib_addr); 834 835 return 0; 836 } 837 EXPORT_SYMBOL_GPL(snd_hdac_stream_set_spib); 838 839 /** 840 * snd_hdac_stream_get_spbmaxfifo - gets the spib value of a stream 841 * @bus: HD-audio core bus 842 * @azx_dev: hdac_stream 843 * 844 * Return maxfifo for the stream 845 */ 846 int snd_hdac_stream_get_spbmaxfifo(struct hdac_bus *bus, 847 struct hdac_stream *azx_dev) 848 { 849 if (!bus->spbcap) { 850 dev_err(bus->dev, "Address of SPB capability is NULL\n"); 851 return -EINVAL; 852 } 853 854 return readl(azx_dev->fifo_addr); 855 } 856 EXPORT_SYMBOL_GPL(snd_hdac_stream_get_spbmaxfifo); 857 858 /** 859 * snd_hdac_stream_drsm_enable - enable DMA resume for a stream 860 * @bus: HD-audio core bus 861 * @enable: flag to enable/disable DRSM 862 * @index: stream index for which DRSM need to be enabled 863 */ 864 void snd_hdac_stream_drsm_enable(struct hdac_bus *bus, 865 bool enable, int index) 866 { 867 u32 mask = 0; 868 869 if (!bus->drsmcap) { 870 dev_err(bus->dev, "Address of DRSM capability is NULL\n"); 871 return; 872 } 873 874 mask |= (1 << index); 875 876 if (enable) 877 snd_hdac_updatel(bus->drsmcap, AZX_REG_DRSM_CTL, mask, mask); 878 else 879 snd_hdac_updatel(bus->drsmcap, AZX_REG_DRSM_CTL, mask, 0); 880 } 881 EXPORT_SYMBOL_GPL(snd_hdac_stream_drsm_enable); 882 883 #ifndef TARGET_OS2 884 /* 885 * snd_hdac_stream_wait_drsm - wait for HW to clear RSM for a stream 886 * @azx_dev: HD-audio core stream to await RSM for 887 * 888 * Returns 0 on success and -ETIMEDOUT upon a timeout. 889 */ 890 int snd_hdac_stream_wait_drsm(struct hdac_stream *azx_dev) 891 { 892 struct hdac_bus *bus = azx_dev->bus; 893 u32 mask, reg; 894 int ret; 895 896 mask = 1 << azx_dev->index; 897 898 ret = read_poll_timeout(snd_hdac_reg_readl, reg, !(reg & mask), 250, 2000, false, bus, 899 bus->drsmcap + AZX_REG_DRSM_CTL); 900 if (ret) 901 dev_dbg(bus->dev, "polling RSM 0x%08x failed: %d\n", mask, ret); 902 return ret; 903 } 904 EXPORT_SYMBOL_GPL(snd_hdac_stream_wait_drsm); 905 #endif 906 907 /** 908 * snd_hdac_stream_set_dpibr - sets the dpibr value of a stream 909 * @bus: HD-audio core bus 910 * @azx_dev: hdac_stream 911 * @value: dpib value to set 912 */ 913 int snd_hdac_stream_set_dpibr(struct hdac_bus *bus, 914 struct hdac_stream *azx_dev, u32 value) 915 { 916 if (!bus->drsmcap) { 917 dev_err(bus->dev, "Address of DRSM capability is NULL\n"); 918 return -EINVAL; 919 } 920 921 writel(value, azx_dev->dpibr_addr); 922 923 return 0; 924 } 925 EXPORT_SYMBOL_GPL(snd_hdac_stream_set_dpibr); 926 927 /** 928 * snd_hdac_stream_set_lpib - sets the lpib value of a stream 929 * @azx_dev: hdac_stream 930 * @value: lpib value to set 931 */ 932 int snd_hdac_stream_set_lpib(struct hdac_stream *azx_dev, u32 value) 933 { 934 snd_hdac_stream_writel(azx_dev, SD_LPIB, value); 935 936 return 0; 937 } 938 EXPORT_SYMBOL_GPL(snd_hdac_stream_set_lpib); 939 682 940 #ifdef CONFIG_SND_HDA_DSP_LOADER 683 941 /** … … 754 1012 { 755 1013 if (start) 756 snd_hdac_stream_start(azx_dev , true);1014 snd_hdac_stream_start(azx_dev); 757 1015 else 758 1016 snd_hdac_stream_stop(azx_dev); -
GPL/trunk/alsa-kernel/hda/hdmi_chmap.c
r709 r772 761 761 } 762 762 763 /* a simple sanity check for input values to chmap kcontrol */ 764 static int chmap_value_check(struct hdac_chmap *hchmap, 765 const struct snd_ctl_elem_value *ucontrol) 766 { 767 int i; 768 769 for (i = 0; i < hchmap->channels_max; i++) { 770 if (ucontrol->value.integer.value[i] < 0 || 771 ucontrol->value.integer.value[i] > SNDRV_CHMAP_LAST) 772 return -EINVAL; 773 } 774 return 0; 775 } 776 763 777 static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol, 764 778 struct snd_ctl_elem_value *ucontrol) … … 772 786 int i, err, ca, prepared = 0; 773 787 788 err = chmap_value_check(hchmap, ucontrol); 789 if (err < 0) 790 return err; 791 774 792 /* No monitor is connected in dyn_pcm_assign. 775 793 * It's invalid to setup the chmap … … 782 800 if (!substream || !substream->runtime) 783 801 return 0; /* just for avoiding error from alsactl restore */ 784 switch (substream->runtime->stat us->state) {802 switch (substream->runtime->state) { 785 803 case SNDRV_PCM_STATE_OPEN: 786 804 case SNDRV_PCM_STATE_SETUP: -
GPL/trunk/alsa-kernel/hda/trace.h
r615 r772 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
Note:
See TracChangeset
for help on using the changeset viewer.
