return ret;
 }
 
+/*
+ * Assume the clock is valid if clock source supports only one single sample
+ * rate, the terminal is connected directly to it (there is no clock selector)
+ * and clock type is internal. This is to deal with some Denon DJ controllers
+ * that always reports that clock is invalid.
+ */
+static bool uac_clock_source_is_valid_quirk(struct snd_usb_audio *chip,
+                                           struct audioformat *fmt,
+                                           int source_id)
+{
+       if (fmt->protocol == UAC_VERSION_2) {
+               struct uac_clock_source_descriptor *cs_desc =
+                       snd_usb_find_clock_source(chip->ctrl_intf, source_id);
+
+               if (!cs_desc)
+                       return false;
+
+               return (fmt->nr_rates == 1 &&
+                       (fmt->clock & 0xff) == cs_desc->bClockID &&
+                       (cs_desc->bmAttributes & 0x3) !=
+                               UAC_CLOCK_SOURCE_TYPE_EXT);
+       }
+
+       return false;
+}
+
 static bool uac_clock_source_is_valid(struct snd_usb_audio *chip,
-                                     int protocol,
+                                     struct audioformat *fmt,
                                      int source_id)
 {
        int err;
        struct usb_device *dev = chip->dev;
        u32 bmControls;
 
-       if (protocol == UAC_VERSION_3) {
+       if (fmt->protocol == UAC_VERSION_3) {
                struct uac3_clock_source_descriptor *cs_desc =
                        snd_usb_find_clock_source_v3(chip->ctrl_intf, source_id);
 
                return false;
        }
 
-       return data ? true :  false;
+       if (data)
+               return true;
+       else
+               return uac_clock_source_is_valid_quirk(chip, fmt, source_id);
 }
 
-static int __uac_clock_find_source(struct snd_usb_audio *chip, int entity_id,
+static int __uac_clock_find_source(struct snd_usb_audio *chip,
+                                  struct audioformat *fmt, int entity_id,
                                   unsigned long *visited, bool validate)
 {
        struct uac_clock_source_descriptor *source;
        source = snd_usb_find_clock_source(chip->ctrl_intf, entity_id);
        if (source) {
                entity_id = source->bClockID;
-               if (validate && !uac_clock_source_is_valid(chip, UAC_VERSION_2,
+               if (validate && !uac_clock_source_is_valid(chip, fmt,
                                                                entity_id)) {
                        usb_audio_err(chip,
                                "clock source %d is not valid, cannot use\n",
                }
 
                cur = ret;
-               ret = __uac_clock_find_source(chip, selector->baCSourceID[ret - 1],
-                                              visited, validate);
+               ret = __uac_clock_find_source(chip, fmt,
+                                             selector->baCSourceID[ret - 1],
+                                             visited, validate);
                if (!validate || ret > 0 || !chip->autoclock)
                        return ret;
 
                        if (i == cur)
                                continue;
 
-                       ret = __uac_clock_find_source(chip, selector->baCSourceID[i - 1],
-                               visited, true);
+                       ret = __uac_clock_find_source(chip, fmt,
+                                                     selector->baCSourceID[i - 1],
+                                                     visited, true);
                        if (ret < 0)
                                continue;
 
        /* FIXME: multipliers only act as pass-thru element for now */
        multiplier = snd_usb_find_clock_multiplier(chip->ctrl_intf, entity_id);
        if (multiplier)
-               return __uac_clock_find_source(chip, multiplier->bCSourceID,
-                                               visited, validate);
+               return __uac_clock_find_source(chip, fmt,
+                                              multiplier->bCSourceID,
+                                              visited, validate);
 
        return -EINVAL;
 }
 
-static int __uac3_clock_find_source(struct snd_usb_audio *chip, int entity_id,
-                                  unsigned long *visited, bool validate)
+static int __uac3_clock_find_source(struct snd_usb_audio *chip,
+                                   struct audioformat *fmt, int entity_id,
+                                   unsigned long *visited, bool validate)
 {
        struct uac3_clock_source_descriptor *source;
        struct uac3_clock_selector_descriptor *selector;
        source = snd_usb_find_clock_source_v3(chip->ctrl_intf, entity_id);
        if (source) {
                entity_id = source->bClockID;
-               if (validate && !uac_clock_source_is_valid(chip, UAC_VERSION_3,
+               if (validate && !uac_clock_source_is_valid(chip, fmt,
                                                                entity_id)) {
                        usb_audio_err(chip,
                                "clock source %d is not valid, cannot use\n",
                }
 
                cur = ret;
-               ret = __uac3_clock_find_source(chip, selector->baCSourceID[ret - 1],
+               ret = __uac3_clock_find_source(chip, fmt,
+                                              selector->baCSourceID[ret - 1],
                                               visited, validate);
                if (!validate || ret > 0 || !chip->autoclock)
                        return ret;
                        if (i == cur)
                                continue;
 
-                       ret = __uac3_clock_find_source(chip, selector->baCSourceID[i - 1],
-                               visited, true);
+                       ret = __uac3_clock_find_source(chip, fmt,
+                                                      selector->baCSourceID[i - 1],
+                                                      visited, true);
                        if (ret < 0)
                                continue;
 
        multiplier = snd_usb_find_clock_multiplier_v3(chip->ctrl_intf,
                                                      entity_id);
        if (multiplier)
-               return __uac3_clock_find_source(chip, multiplier->bCSourceID,
+               return __uac3_clock_find_source(chip, fmt,
+                                               multiplier->bCSourceID,
                                                visited, validate);
 
        return -EINVAL;
  *
  * Returns the clock source UnitID (>=0) on success, or an error.
  */
-int snd_usb_clock_find_source(struct snd_usb_audio *chip, int protocol,
-                             int entity_id, bool validate)
+int snd_usb_clock_find_source(struct snd_usb_audio *chip,
+                             struct audioformat *fmt, bool validate)
 {
        DECLARE_BITMAP(visited, 256);
        memset(visited, 0, sizeof(visited));
 
-       switch (protocol) {
+       switch (fmt->protocol) {
        case UAC_VERSION_2:
-               return __uac_clock_find_source(chip, entity_id, visited,
+               return __uac_clock_find_source(chip, fmt, fmt->clock, visited,
                                               validate);
        case UAC_VERSION_3:
-               return __uac3_clock_find_source(chip, entity_id, visited,
+               return __uac3_clock_find_source(chip, fmt, fmt->clock, visited,
                                               validate);
        default:
                return -EINVAL;
         * automatic clock selection if the current clock is not
         * valid.
         */
-       clock = snd_usb_clock_find_source(chip, fmt->protocol,
-                                         fmt->clock, true);
+       clock = snd_usb_clock_find_source(chip, fmt, true);
        if (clock < 0) {
                /* We did not find a valid clock, but that might be
                 * because the current sample rate does not match an
                 * and we will do another validation after setting the
                 * rate.
                 */
-               clock = snd_usb_clock_find_source(chip, fmt->protocol,
-                                                 fmt->clock, false);
+               clock = snd_usb_clock_find_source(chip, fmt, false);
                if (clock < 0)
                        return clock;
        }
 
 validation:
        /* validate clock after rate change */
-       if (!uac_clock_source_is_valid(chip, fmt->protocol, clock))
+       if (!uac_clock_source_is_valid(chip, fmt, clock))
                return -ENXIO;
        return 0;
 }