Ignore:
Timestamp:
Apr 19, 2025, 8:08:37 PM (7 months ago)
Author:
David Azarewicz
Message:

Merge in changes from 6.6-LTS branch.
Fixed additional 25+ problems.

Location:
GPL/trunk
Files:
12 edited
2 copied

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/hda/Makefile

    r709 r772  
    1313#
    1414#===================================================================
    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
     15FILES = 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
    1617
    1718TARGET = hdac
  • GPL/trunk/alsa-kernel/hda/ext/hdac_ext_bus.c

    r629 r772  
    6060}
    6161EXPORT_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 device
    70  * @bus: hdac bus to attach to
    71  * @addr: codec address
    72  * @hdev: hdac device to init
    73  * @type: codec type (HDAC_DEV_*) to use for this device
    74  *
    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 device
    108  * @hdev: hdac device to clean up
    109  */
    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);
    11562
    11663/**
  • GPL/trunk/alsa-kernel/hda/ext/hdac_ext_controller.c

    r695 r772  
    1414#include <sound/hda_register.h>
    1515#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 HW
    21  */
    22 #define HDAC_MAX_CAPS 10
    2316
    2417/*
     
    116109
    117110/**
    118  * snd_hdac_link_free_all- free hdac extended link objects
    119  *
    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
     116void snd_hdac_ext_link_free_all(struct hdac_bus *bus)
     117{
     118        struct hdac_ext_link *hlink;
    126119
    127120        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}
     126EXPORT_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 */
     135struct 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}
     144EXPORT_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
    137148 * @bus: the pointer to HDAC bus object
    138149 * @codec_name: codec name
    139150 */
    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;
     151struct hdac_ext_link *snd_hdac_ext_bus_get_hlink_by_name(struct hdac_bus *bus,
     152                                                         const char *codec_name)
     153{
    145154        int bus_idx, addr;
    146155
     
    152161                return NULL;
    153162
    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}
     165EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_get_hlink_by_name);
     166
     167static int check_hdac_link_power_active(struct hdac_ext_link *hlink, bool enable)
    166168{
    167169        int timeout;
    168170        u32 val;
    169         int mask = (1 << AZX_MLCTL_CPA_SHIFT);
     171        int mask = (1 << AZX_ML_LCTL_CPA_SHIFT);
    170172
    171173        udelay(3);
     
    173175
    174176        do {
    175                 val = readl(link->ml_addr + AZX_REG_ML_LCTL);
     177                val = readl(hlink->ml_addr + AZX_REG_ML_LCTL);
    176178                if (enable) {
    177                         if (((val & mask) >> AZX_MLCTL_CPA_SHIFT))
     179                        if (((val & mask) >> AZX_ML_LCTL_CPA_SHIFT))
    178180                                return 0;
    179181                } else {
    180                         if (!((val & mask) >> AZX_MLCTL_CPA_SHIFT))
     182                        if (!((val & mask) >> AZX_ML_LCTL_CPA_SHIFT))
    181183                                return 0;
    182184                }
     
    189191/**
    190192 * snd_hdac_ext_bus_link_power_up -power up hda link
    191  * @link: HD-audio extended link
    192  */
    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_MLCTL_SPA, AZX_MLCTL_SPA);
    197 
    198         return check_hdac_link_power_active(link, true);
     193 * @hlink: HD-audio extended link
     194 */
     195int 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);
    199201}
    200202EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_power_up);
     
    202204/**
    203205 * snd_hdac_ext_bus_link_power_down -power down hda link
    204  * @link: HD-audio extended link
    205  */
    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 */
     208int 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);
    211213}
    212214EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_power_down);
     
    222224
    223225        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);
    227227                if (ret < 0)
    228228                        return ret;
     
    243243
    244244        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);
    248246                if (ret < 0)
    249247                        return ret;
     
    254252EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_power_down_all);
    255253
     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 */
     259void 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}
     264EXPORT_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 */
     271void 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}
     276EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_clear_stream_id);
     277
    256278int snd_hdac_ext_bus_link_get(struct hdac_bus *bus,
    257                                 struct hdac_ext_link *link)
     279                                struct hdac_ext_link *hlink)
    258280{
    259281        unsigned long codec_mask;
     
    266288         * as well, also check the dma status and trigger that
    267289         */
    268         if (++link->ref_count == 1) {
     290        if (++hlink->ref_count == 1) {
    269291                if (!bus->cmd_dma_state) {
    270292                        snd_hdac_bus_init_cmd_io(bus);
     
    272294                }
    273295
    274                 ret = snd_hdac_ext_bus_link_power_up(link);
     296                ret = snd_hdac_ext_bus_link_power_up(hlink);
    275297
    276298                /*
    277299                 * clear the register to invalidate all the output streams
    278300                 */
    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);
    281303                /*
    282304                 *  wait for 521usec for codec to report status
     
    297319
    298320int snd_hdac_ext_bus_link_put(struct hdac_bus *bus,
    299                                 struct hdac_ext_link *link)
     321                              struct hdac_ext_link *hlink)
    300322{
    301323        int ret = 0;
    302         struct hdac_ext_link *hlink;
     324        struct hdac_ext_link *hlink_tmp;
    303325        bool link_up = false;
    304326
     
    309331         * so power down this link as well
    310332         */
    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);
    313335
    314336                /*
     
    316338                 * cmd dma as well
    317339                 */
    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) {
    320342                                link_up = true;
    321343                                break;
     
    338360        const char *devname = dev_name(&codec->dev);
    339361        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);
    341363
    342364        if (hlink)
     
    348370        const char *devname = dev_name(&codec->dev);
    349371        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);
    351373
    352374        if (hlink)
  • GPL/trunk/alsa-kernel/hda/ext/hdac_ext_stream.c

    r717 r772  
    1515#include <sound/hda_register.h>
    1616#include <sound/hdaudio_ext.h>
     17#include <sound/compress_driver.h>
    1718
    1819/**
    1920 * snd_hdac_ext_stream_init - initialize each stream (aka device)
    2021 * @bus: HD-audio core bus
    21  * @stream: HD-audio ext core stream object to initialize
     22 * @hext_stream: HD-audio ext core stream object to initialize
    2223 * @idx: stream index number
    2324 * @direction: stream direction (SNDRV_PCM_STREAM_PLAYBACK or SNDRV_PCM_STREAM_CAPTURE)
     
    2728 * invoke hdac stream initialization routine
    2829 */
    29 void snd_hdac_ext_stream_init(struct hdac_bus *bus,
    30                                 struct hdac_ext_stream *stream,
    31                                 int idx, int direction, int tag)
     30static void snd_hdac_ext_stream_init(struct hdac_bus *bus,
     31                                     struct hdac_ext_stream *hext_stream,
     32                                     int idx, int direction, int tag)
    3233{
    3334        if (bus->ppcap) {
    34                 stream->pphc_addr = bus->ppcap + AZX_PPHC_BASE +
     35                hext_stream->pphc_addr = bus->ppcap + AZX_PPHC_BASE +
    3536                                AZX_PPHC_INTERVAL * idx;
    3637
    37                 stream->pplc_addr = bus->ppcap + AZX_PPLC_BASE +
     38                hext_stream->pplc_addr = bus->ppcap + AZX_PPLC_BASE +
    3839                                AZX_PPLC_MULTI * bus->num_streams +
    3940                                AZX_PPLC_INTERVAL * idx;
    4041        }
    4142
    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}
    6046
    6147/**
     
    6854 */
    6955int 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)
    7157{
    7258        int stream_tag = 0;
     
    7460
    7561        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)
    7965                        return -ENOMEM;
    8066                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);
    8268                idx++;
    8369        }
     
    8975
    9076/**
    91  * snd_hdac_stream_free_all - free hdac extended stream objects
    92  *
    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 */
     81void snd_hdac_ext_stream_free_all(struct hdac_bus *bus)
    9682{
    9783        struct hdac_stream *s, *_s;
    98         struct hdac_ext_stream *stream;
     84        struct hdac_ext_stream *hext_stream;
    9985
    10086        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);
    10389                list_del(&s->list);
    104                 kfree(stream);
    105         }
    106 }
    107 EXPORT_SYMBOL_GPL(snd_hdac_stream_free_all);
     90                kfree(hext_stream);
     91        }
     92}
     93EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_free_all);
    10894
    10995void snd_hdac_ext_stream_decouple_locked(struct hdac_bus *bus,
    110                                          struct hdac_ext_stream *stream,
     96                                         struct hdac_ext_stream *hext_stream,
    11197                                         bool decouple)
    11298{
    113         struct hdac_stream *hstream = &stream->hstream;
     99        struct hdac_stream *hstream = &hext_stream->hstream;
    114100        u32 val;
    115101        int mask = AZX_PPCTL_PROCEN(hstream->index);
     
    122108                snd_hdac_updatel(bus->ppcap, AZX_REG_PP_PPCTL, mask, 0);
    123109
    124         stream->decoupled = decouple;
     110        hext_stream->decoupled = decouple;
    125111}
    126112EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_decouple_locked);
     
    129115 * snd_hdac_ext_stream_decouple - decouple the hdac stream
    130116 * @bus: HD-audio core bus
    131  * @stream: HD-audio ext core stream object to initialize
     117 * @hext_stream: HD-audio ext core stream object to initialize
    132118 * @decouple: flag to decouple
    133119 */
    134120void 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)
    136122{
    137123        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);
    139125        spin_unlock_irq(&bus->reg_lock);
    140126}
     
    142128
    143129/**
    144  * snd_hdac_ext_link_stream_start - start a stream
    145  * @stream: HD-audio ext core stream to start
    146  */
    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 */
     133void snd_hdac_ext_stream_start(struct hdac_ext_stream *hext_stream)
     134{
     135        snd_hdac_updatel(hext_stream->pplc_addr, AZX_REG_PPLCCTL,
    150136                         AZX_PPLCCTL_RUN, AZX_PPLCCTL_RUN);
    151137}
    152 EXPORT_SYMBOL_GPL(snd_hdac_ext_link_stream_start);
    153 
    154 /**
    155  * snd_hdac_ext_link_stream_clear - stop a stream DMA
    156  * @stream: HD-audio ext core stream to stop
    157  */
    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 stream
    166  * @stream: HD-audio ext core stream to reset
    167  */
    168 void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *stream)
     138EXPORT_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 */
     144void 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}
     148EXPORT_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 */
     154void snd_hdac_ext_stream_reset(struct hdac_ext_stream *hext_stream)
    169155{
    170156        unsigned char val;
    171157        int timeout;
    172158
    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,
    176162                         AZX_PPLCCTL_STRST, AZX_PPLCCTL_STRST);
    177163        udelay(3);
    178164        timeout = 50;
    179165        do {
    180                 val = readl(stream->pplc_addr + AZX_REG_PPLCCTL) &
     166                val = readl(hext_stream->pplc_addr + AZX_REG_PPLCCTL) &
    181167                                AZX_PPLCCTL_STRST;
    182168                if (val)
     
    185171        } while (--timeout);
    186172        val &= ~AZX_PPLCCTL_STRST;
    187         writel(val, stream->pplc_addr + AZX_REG_PPLCCTL);
     173        writel(val, hext_stream->pplc_addr + AZX_REG_PPLCCTL);
    188174        udelay(3);
    189175
     
    191177        /* waiting for hardware to report that the stream is out of reset */
    192178        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;
    194180                if (!val)
    195181                        break;
     
    198184
    199185}
    200 EXPORT_SYMBOL_GPL(snd_hdac_ext_link_stream_reset);
    201 
    202 /**
    203  * snd_hdac_ext_link_stream_setup -  set up the SD for streaming
    204  * @stream: HD-audio ext core stream to set up
     186EXPORT_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
    205191 * @fmt: stream format
    206192 */
    207 int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *stream, int fmt)
    208 {
    209         struct hdac_stream *hstream = &stream->hstream;
     193int snd_hdac_ext_stream_setup(struct hdac_ext_stream *hext_stream, int fmt)
     194{
     195        struct hdac_stream *hstream = &hext_stream->hstream;
    210196        unsigned int val;
    211197
    212198        /* 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);
    214200        /* program the stream_tag */
    215         val = readl(stream->pplc_addr + AZX_REG_PPLCCTL);
     201        val = readl(hext_stream->pplc_addr + AZX_REG_PPLCCTL);
    216202        val = (val & ~AZX_PPLCCTL_STRM_MASK) |
    217203                (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);
    219205
    220206        /* program the stream format */
    221         writew(fmt, stream->pplc_addr + AZX_REG_PPLCFMT);
     207        writew(fmt, hext_stream->pplc_addr + AZX_REG_PPLCFMT);
    222208
    223209        return 0;
    224210}
    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);
     211EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_setup);
    250212
    251213static struct hdac_ext_stream *
    252 hdac_ext_link_stream_assign(struct hdac_bus *bus,
     214hdac_ext_link_dma_stream_assign(struct hdac_bus *bus,
    253215                                struct snd_pcm_substream *substream)
    254216{
    255217        struct hdac_ext_stream *res = NULL;
    256         struct hdac_stream *stream = NULL;
     218        struct hdac_stream *hstream = NULL;
    257219
    258220        if (!bus->ppcap) {
     
    262224
    263225        spin_lock_irq(&bus->reg_lock);
    264         list_for_each_entry(stream, &bus->stream_list, list) {
    265                 struct hdac_ext_stream *hstream = 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)
    269231                        continue;
    270232
    271                 /* check if decoupled stream and not in use is available */
    272                 if (hstream->decoupled && !hstream->link_locked) {
    273                         res = hstream;
     233                /* check if link stream is available */
     234                if (!hext_stream->link_locked) {
     235                        res = hext_stream;
    274236                        break;
    275237                }
    276238
    277                 if (!hstream->link_locked) {
    278                         snd_hdac_ext_stream_decouple_locked(bus, hstream, true);
    279                         res = hstream;
    280                         break;
    281                 }
    282239        }
    283240        if (res) {
     241                snd_hdac_ext_stream_decouple_locked(bus, res, true);
    284242                res->link_locked = 1;
    285243                res->link_substream = substream;
     
    290248
    291249static struct hdac_ext_stream *
    292 hdac_ext_host_stream_assign(struct hdac_bus *bus,
     250hdac_ext_host_dma_stream_assign(struct hdac_bus *bus,
    293251                                struct snd_pcm_substream *substream)
    294252{
    295253        struct hdac_ext_stream *res = NULL;
    296         struct hdac_stream *stream = NULL;
     254        struct hdac_stream *hstream = NULL;
    297255
    298256        if (!bus->ppcap) {
     
    302260
    303261        spin_lock_irq(&bus->reg_lock);
    304         list_for_each_entry(stream, &bus->stream_list, list) {
    305                 struct hdac_ext_stream *hstream = 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)
    309267                        continue;
    310268
    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;
    315271                        break;
    316272                }
    317273        }
    318274        if (res) {
     275                snd_hdac_ext_stream_decouple_locked(bus, res, true);
    319276                res->hstream.opened = 1;
    320277                res->hstream.running = 0;
     
    347304                                           int type)
    348305{
    349         struct hdac_ext_stream *hstream = NULL;
    350         struct hdac_stream *stream = NULL;
     306        struct hdac_ext_stream *hext_stream = NULL;
     307        struct hdac_stream *hstream = NULL;
    351308
    352309        switch (type) {
    353310        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;
    359317
    360318        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);
    362320
    363321        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);
    365323
    366324        default:
     
    372330/**
    373331 * snd_hdac_ext_stream_release - release the assigned stream
    374  * @stream: HD-audio ext core stream to release
     332 * @hext_stream: HD-audio ext core stream to release
    375333 * @type: type of stream (coupled, host or link stream)
    376334 *
    377335 * Release the stream that has been assigned by snd_hdac_ext_stream_assign().
    378336 */
    379 void snd_hdac_ext_stream_release(struct hdac_ext_stream *stream, int type)
    380 {
    381         struct hdac_bus *bus = stream->hstream.bus;
     337void snd_hdac_ext_stream_release(struct hdac_ext_stream *hext_stream, int type)
     338{
     339        struct hdac_bus *bus = hext_stream->hstream.bus;
    382340
    383341        switch (type) {
    384342        case HDAC_EXT_STREAM_TYPE_COUPLED:
    385                 snd_hdac_stream_release(&stream->hstream);
     343                snd_hdac_stream_release(&hext_stream->hstream);
    386344                break;
    387345
    388346        case HDAC_EXT_STREAM_TYPE_HOST:
    389347                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);
    392352                spin_unlock_irq(&bus->reg_lock);
    393                 snd_hdac_stream_release(&stream->hstream);
    394353                break;
    395354
    396355        case HDAC_EXT_STREAM_TYPE_LINK:
    397356                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;
    402362                spin_unlock_irq(&bus->reg_lock);
    403363                break;
     
    411371
    412372/**
    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 */
     381struct 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}
     410EXPORT_SYMBOL_GPL(snd_hdac_ext_cstream_assign);
  • GPL/trunk/alsa-kernel/hda/hdac_bus.c

    r695 r772  
    194194                        continue;
    195195                codec = bus->caddr_tbl[caddr & 0x0f];
    196                 if (!codec || !codec->dev.driver)
     196                if (!codec || !codec->registered)
    197197                        continue;
    198198                spin_unlock_irq(&bus->reg_lock);
  • GPL/trunk/alsa-kernel/hda/hdac_component.c

    r764 r772  
    194194                return ret;
    195195
     196  #ifndef TARGET_OS2
    196197        if (WARN_ON(!(acomp->dev && acomp->ops))) {
    197198                ret = -EINVAL;
    198199                goto out_unbind;
    199200        }
     201        #endif
    200202
    201203        /* pin the module to avoid dynamic unbinding, but only if given */
  • GPL/trunk/alsa-kernel/hda/hdac_controller.c

    r717 r772  
    8080        snd_hdac_chip_writew(bus, RINTCNT, 1);
    8181        /* 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);
    8386        /* Accept unsolicited responses */
    8487        snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_UNSOL, AZX_GCTL_UNSOL);
     
    481484                snd_hdac_stream_updateb(azx_dev, SD_CTL, SD_INT_MASK, 0);
    482485
    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);
    488488}
    489489
     
    588588                        snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK);
    589589                        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))
    592592                                continue;
    593593                        if (ack)
  • GPL/trunk/alsa-kernel/hda/hdac_device.c

    r717 r772  
    212212 * Returns the size of string, like snprintf(), or a negative error code.
    213213 */
    214 int snd_hdac_codec_modalias(struct hdac_device *codec, char *buf, size_t size)
     214int snd_hdac_codec_modalias(const struct hdac_device *codec, char *buf, size_t size)
    215215{
    216216        return scnprintf(buf, size, "hdaudio:v%08Xr%08Xa%02X\n",
     
    623623#if 0 //fixme
    624624        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);
    626626                if (!ret)
    627627                        return -1;
     
    660660
    661661static const struct hda_vendor_id hda_vendor_ids[] = {
     662        { 0x0014, "Loongson" },
    662663        { 0x1002, "ATI" },
    663664        { 0x1013, "Cirrus Logic" },
  • GPL/trunk/alsa-kernel/hda/hdac_regmap.c

    r695 r772  
    1818#include <linux/export.h>
    1919#include <linux/pm.h>
    20 #include <linux/pm_runtime.h>
    2120#include <sound/core.h>
    2221#include <sound/hdaudio.h>
     
    359358        .readable_reg = hda_readable_reg,
    360359        .volatile_reg = hda_volatile_reg,
     360#ifndef TARGET_OS2
     361        .cache_type = REGCACHE_MAPLE,
     362#else
    361363        .cache_type = REGCACHE_RBTREE,
     364#endif
    362365        .reg_read = hda_reg_read,
    363366        .reg_write = hda_reg_write,
     
    570573                               unsigned int mask, unsigned int val)
    571574{
     575#ifndef TARGET_OS2
     576        int err = 0;
     577#else
    572578        unsigned int orig;
    573579        int err;
    574 
     580#endif
    575581        if (!codec->regmap)
    576582                return reg_raw_update(codec, reg, mask, val);
    577583
    578584        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
    579589        regcache_cache_only(codec->regmap, true);
    580590        err = regmap_read(codec->regmap, reg, &orig);
    581591        regcache_cache_only(codec->regmap, false);
    582592        if (err < 0)
     593#endif
    583594                err = regmap_update_bits(codec->regmap, reg, mask, val);
    584595        mutex_unlock(&codec->regmap_lock);
     
    614625void snd_hdac_regmap_sync(struct hdac_device *codec)
    615626{
    616         if (codec->regmap) {
    617                 mutex_lock(&codec->regmap_lock);
     627        mutex_lock(&codec->regmap_lock);
     628        if (codec->regmap)
    618629                regcache_sync(codec->regmap);
    619                 mutex_unlock(&codec->regmap_lock);
    620         }
     630        mutex_unlock(&codec->regmap_lock);
    621631}
    622632EXPORT_SYMBOL_GPL(snd_hdac_regmap_sync);
  • GPL/trunk/alsa-kernel/hda/hdac_stream.c

    r717 r772  
    88#include <linux/export.h>
    99#include <linux/clocksource.h>
     10#include <sound/compress_driver.h>
    1011#include <sound/core.h>
    1112#include <sound/pcm.h>
     
    1920#endif
    2021
     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
    2155/**
    2256 * snd_hdac_get_stream_stripe_ctl - get stripe control value
     
    76110        snd_hdac_dsp_lock_init(azx_dev);
    77111        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;
    78126}
    79127EXPORT_SYMBOL_GPL(snd_hdac_stream_init);
     
    82130 * snd_hdac_stream_start - start a stream
    83131 * @azx_dev: HD-audio core stream to start
    84  * @fresh_start: false = wallclock timestamp relative to period wallclock
    85132 *
    86133 * Start a stream, set start_wallclk and set the running flag.
    87134 */
    88 void snd_hdac_stream_start(struct hdac_stream *azx_dev, bool fresh_start)
     135void snd_hdac_stream_start(struct hdac_stream *azx_dev)
    89136{
    90137        struct hdac_bus *bus = azx_dev->bus;
     
    94141
    95142        azx_dev->start_wallclk = snd_hdac_chip_readl(bus, WALLCLK);
    96         if (!fresh_start)
    97                 azx_dev->start_wallclk -= azx_dev->period_wallclk;
    98143
    99144        /* enable SIE */
     
    111156        }
    112157        /* 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,
    114163                                0, SD_CTL_DMA_START | SD_INT_MASK);
    115164        azx_dev->running = true;
     
    118167
    119168/**
    120  * snd_hdac_stream_clear - stop a stream DMA
     169 * snd_hdac_stream_clear - helper to clear stream registers and stop DMA transfers
    121170 * @azx_dev: HD-audio core stream to stop
    122171 */
    123 void snd_hdac_stream_clear(struct hdac_stream *azx_dev)
     172static void snd_hdac_stream_clear(struct hdac_stream *azx_dev)
    124173{
    125174        snd_hdac_stream_updateb(azx_dev, SD_CTL,
     
    130179        azx_dev->running = false;
    131180}
    132 EXPORT_SYMBOL_GPL(snd_hdac_stream_clear);
    133181
    134182/**
     
    149197
    150198/**
     199 * snd_hdac_stop_streams - stop all streams
     200 * @bus: HD-audio core bus
     201 */
     202void 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}
     209EXPORT_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 */
     215void 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}
     222EXPORT_SYMBOL_GPL(snd_hdac_stop_streams_and_chip);
     223
     224/**
    151225 * snd_hdac_stream_reset - reset a stream
    152226 * @azx_dev: HD-audio core stream to reset
     
    155229{
    156230        unsigned char val;
     231#ifdef TARGET_OS2
    157232        int timeout;
     233#endif
    158234        int dma_run_state;
    159235
     
    163239
    164240        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
    165246        udelay(3);
    166247        timeout = 300;
     
    171252                        break;
    172253        } while (--timeout);
    173 
     254#endif
    174255        if (azx_dev->bus->dma_stop_delay && dma_run_state)
    175256                udelay(azx_dev->bus->dma_stop_delay);
    176257
    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
    179264        udelay(3);
    180265
     
    187272                        break;
    188273        } while (--timeout);
    189 
     274#endif
    190275        /* reset first position - may not be synced with hw at this time */
    191276        if (azx_dev->posbuf)
     
    299384
    300385        /* 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);
    303390
    304391        spin_lock_irq(&bus->reg_lock);
     
    327414
    328415/**
    329  * snd_hdac_stream_release - release the assigned stream
     416 * snd_hdac_stream_release_locked - release the assigned stream
    330417 * @azx_dev: HD-audio core stream to release
    331418 *
    332419 * 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 */
     422void snd_hdac_stream_release_locked(struct hdac_stream *azx_dev)
     423{
    339424        azx_dev->opened = 0;
    340425        azx_dev->running = 0;
    341426        azx_dev->substream = NULL;
     427}
     428EXPORT_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 */
     436void 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);
    342442        spin_unlock_irq(&bus->reg_lock);
    343443}
     
    421521        struct hdac_bus *bus = azx_dev->bus;
    422522        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;
    424526        __le32 *bdl;
    425527        int i, ofs, periods, period_bytes;
    426528        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        }
    427539
    428540        /* reset BDL address */
     
    439551
    440552        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) {
    442554                pos_align = pos_adj;
    443555                pos_adj = DIV_ROUND_UP(pos_adj * runtime->rate, 48000);
     
    452564                        pos_adj = 0;
    453565                } else {
    454                         ofs = setup_bdle(bus, snd_pcm_get_dma_buf(substream),
    455                                          azx_dev,
     566                        ofs = setup_bdle(bus, dmab, azx_dev,
    456567                                         &bdl, ofs, pos_adj, true);
    457568                        if (ofs < 0)
     
    463574        for (i = 0; i < periods; i++) {
    464575                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);
    468578                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,
    472581                                         !azx_dev->no_period_wakeup);
    473582                if (ofs < 0)
     
    494603                                 unsigned int format_val)
    495604{
    496 
     605        struct snd_pcm_substream *substream = azx_dev->substream;
     606        struct snd_compr_stream *cstream = azx_dev->cstream;
    497607        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;
    500609        int err;
    501610
    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 {
    503620                return -EINVAL;
    504         runtime = substream->runtime;
    505         bufsize = snd_pcm_lib_buffer_bytes(substream);
    506         period_bytes = snd_pcm_lib_period_bytes(substream);
     621        }
    507622
    508623        if (bufsize != azx_dev->bufsize ||
    509624            period_bytes != azx_dev->period_bytes ||
    510625            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) {
    512627                azx_dev->bufsize = bufsize;
    513628                azx_dev->period_bytes = period_bytes;
    514629                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;
    516631                err = snd_hdac_stream_setup_periods(azx_dev);
    517632                if (err < 0)
     
    589704        bool inited = false;
    590705        u64 cycle_last = 0;
    591         int i = 0;
    592706
    593707        list_for_each_entry(s, &bus->stream_list, list, struct hdac_stream) {
    594                 if (streams & (1 << i)) {
     708                if ((streams & (1 << s->index))) {
    595709                        azx_timecounter_init(s, inited, cycle_last);
    596710                        if (!inited) {
     
    599713                        }
    600714                }
    601                 i++;
    602715        }
    603716
     
    644757{
    645758        struct hdac_bus *bus = azx_dev->bus;
    646         int i, nwait, timeout;
     759        int nwait, timeout;
    647760        struct hdac_stream *s;
    648761
    649762        for (timeout = 5000; timeout; timeout--) {
    650763                nwait = 0;
    651                 i = 0;
    652764                list_for_each_entry(s, &bus->stream_list, list, struct hdac_stream) {
    653                         if (!(streams & (1 << i++)))
     765                        if (!(streams & (1 << s->index)))
    654766                                continue;
    655767
     
    680792EXPORT_SYMBOL_GPL(snd_hdac_stream_sync);
    681793
     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 */
     800void 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}
     817EXPORT_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 */
     825int 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}
     837EXPORT_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 */
     846int 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}
     856EXPORT_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 */
     864void 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}
     881EXPORT_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 */
     890int 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}
     904EXPORT_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 */
     913int 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}
     925EXPORT_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 */
     932int 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}
     938EXPORT_SYMBOL_GPL(snd_hdac_stream_set_lpib);
     939
    682940#ifdef CONFIG_SND_HDA_DSP_LOADER
    683941/**
     
    7541012{
    7551013        if (start)
    756                 snd_hdac_stream_start(azx_dev, true);
     1014                snd_hdac_stream_start(azx_dev);
    7571015        else
    7581016                snd_hdac_stream_stop(azx_dev);
  • GPL/trunk/alsa-kernel/hda/hdmi_chmap.c

    r709 r772  
    761761}
    762762
     763/* a simple sanity check for input values to chmap kcontrol */
     764static 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
    763777static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol,
    764778                              struct snd_ctl_elem_value *ucontrol)
     
    772786        int i, err, ca, prepared = 0;
    773787
     788        err = chmap_value_check(hchmap, ucontrol);
     789        if (err < 0)
     790                return err;
     791
    774792        /* No monitor is connected in dyn_pcm_assign.
    775793         * It's invalid to setup the chmap
     
    782800        if (!substream || !substream->runtime)
    783801                return 0; /* just for avoiding error from alsactl restore */
    784         switch (substream->runtime->status->state) {
     802        switch (substream->runtime->state) {
    785803        case SNDRV_PCM_STATE_OPEN:
    786804        case SNDRV_PCM_STATE_SETUP:
  • GPL/trunk/alsa-kernel/hda/trace.h

    r615 r772  
    2020        TP_PROTO(struct hdac_bus *bus, unsigned int cmd),
    2121        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        ),
    2326        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;
    2729        ),
    28         TP_printk("%s", __get_str(msg))
     30        TP_printk("[%s:%d] val=0x%08x", __get_str(name), __entry->cmd >> 28, __entry->cmd)
    2931);
    3032
     
    3234        TP_PROTO(struct hdac_bus *bus, unsigned int addr, unsigned int res),
    3335        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        ),
    3541        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;
    3945        ),
    40         TP_printk("%s", __get_str(msg))
     46        TP_printk("[%s:%d] val=0x%08x", __get_str(name), __entry->addr, __entry->res)
    4147);
    4248
     
    4450        TP_PROTO(struct hdac_bus *bus, u32 res, u32 res_ex),
    4551        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        ),
    4757        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;
    5161        ),
    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)
    5364);
    5465
Note: See TracChangeset for help on using the changeset viewer.