ALSA: hda: add member to store ratio for stripe control
authorSameer Pujar <spujar@nvidia.com>
Mon, 4 May 2020 08:16:15 +0000 (13:46 +0530)
committerTakashi Iwai <tiwai@suse.de>
Mon, 4 May 2020 09:51:23 +0000 (11:51 +0200)
Stripe control programming is governed by following formula, which is
referenced from the HD Audio specification(Revision 1.0a).
  { ((num_channels * bits_per_sample) / number of SDOs) >= 8 }

Currently above is implemented in snd_hdac_get_stream_stripe_ctl().
This patch introduces a structure member to store the default factor
of '8'. If any HW wants to use a different value, this member can be
easily updated.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1588580176-2801-3-git-send-email-spujar@nvidia.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/hdaudio.h
sound/hda/hdac_controller.c
sound/hda/hdac_stream.c

index affedc2801c4be7910344efa1797807a3fffd320..d365297b369831a390f270f35a88ac9db7b2a7f1 100644 (file)
@@ -364,6 +364,9 @@ struct hdac_bus {
        /* link management */
        struct list_head hlink_list;
        bool cmd_dma_state;
+
+       /* factor used to derive STRIPE control value */
+       unsigned int sdo_limit;
 };
 
 int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev,
index bc4a8b606020a1e5f715377f172d3348dd77a87e..ac15aa357fbd32a8a908cb6f416ff641e4c4e582 100644 (file)
@@ -527,6 +527,18 @@ bool snd_hdac_bus_init_chip(struct hdac_bus *bus, bool full_reset)
        }
 
        bus->chip_init = true;
+
+       /*
+        * Default value of '8' is as per the HD audio specification (Rev 1.0a).
+        * Following relation is used to derive STRIPE control value.
+        *  For sample rate <= 48K:
+        *   { ((num_channels * bits_per_sample) / number of SDOs) >= 8 }
+        *  For sample rate > 48K:
+        *   { ((num_channels * bits_per_sample * rate/48000) /
+        *      number of SDOs) >= 8 }
+        */
+       bus->sdo_limit = 8;
+
        return true;
 }
 EXPORT_SYMBOL_GPL(snd_hdac_bus_init_chip);
index a314b03b4a4cb1696d87ee57d5f5ed8d21eecb26..a38a2af1654f72a0bf50b5c8e07b3d108980c856 100644 (file)
@@ -38,7 +38,7 @@ int snd_hdac_get_stream_stripe_ctl(struct hdac_bus *bus,
                else
                        value = (channels * bits_per_sample) / sdo_line;
 
-               if (value >= 8)
+               if (value >= bus->sdo_limit)
                        break;
        }