Don't set alsa_rt->hw.rates in hiface_pcm_open()

FWIU setting alsa_rt->hw.rates in the open callback can be useful when
different hardware revisions or different stream types have different
capabilities, but in our case it should not be needed as we only have
one playback stream and we define the capabilities via constraints
already to avoid invalid rates to be used.

Moreover, following the code it seems impossible to get to setting
alsa_rt->hw.rates:

  hiface_pcm_init:
    rt->rate = ARRAY_SIZE(rates);

  hiface_pcm_open:
    if (rt->rate < ARRAY_SIZE(rates))
      alsa_rt->hw.rates = rates_alsaid[rt->rate];
      /* So it does not get here on the first open */

  hiface_pcm_prepare:
    hiface_pcm_set_rate:
      for (rt->rate = 0; rt->rate < ARRAY_SIZE(rates); rt->rate++)
        if (rate == rates[rt->rate])
          break;

  hiface_pcm_close:
    rt->rate = ARRAY_SIZE(rates);
    /* So it won't set alsa_rt->hw.rates at the next open either */

So the only way to set alsa_rt->hw.rates is to have two calls to the
open callback, is that even possible? ALSA does not allow sharing PCM
streams AFAIK and we use only one playback stream.

Maybe the 6fire driver was setting alsa_rt->hw.rates in order to have
the playback stream and the capture stream use the same rate? I.e. the
first open,prepare,set_rate() sequence on one type of stream will decide
the rate and the second open on the other type would restrict the
supported rate to the one already in use, but I am not sure.

If the rationale makes sense then we don't need to set alsa_rt->hw.rates
and we can remove this code.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Style cleanup, no braces needed in single statement conditional

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Remove the rate field from pcm_runtime

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Use the hiFace name with the lowercase 'h' everywhere

We are using this name in the commit message for the mainline inclusion
too, so let's be consistent.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
List actually supported devices in MODULE_SUPPORTED_DEVICE()

Do as suggested by Clemens Ladisch.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Cosmetics, align values in the rates array

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Use an explicit switch instead of the rate_value array in hiface_pcm_set_rate()

This just tells exactly what we are doing, in a more transparent way
than a for loop.

Also use some symbolic constants to highlight the mapping between the
sample rate and the value to send via USB.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Use usb_make_path() when building card->longname

This was suggested by Clemens Ladisch

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Use again the implicit mechanism to allocate the card private data

Our hiface_dev_free() has now been simplified so that it just calls
kfree(), so the implicit mechanism is suitable again for us to use.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Downgrade a pr_info to pr_debug in hiface_chip_probe()

As requested by Clemens Ladisch

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Make device_table const

Suggested by Clemens Ladisch.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Rename PCM_MAX_PACKET_SIZE to PCM_PACKET_SIZE

Suggested by Clemens Ladisch.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Rename MAX_BUFSIZE to PCM_BUFFER_SIZE

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Cosmetics, align symbolic constant values

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Add SNDRV_PCM_RATE_KNOT only when needed

Add SNDRV_PCM_RATE_KNOT only when extra frequencies are allowed, and in
this case set up explicit constraints for the supported rates.

Now constraints_rates can also be const as we don't chage its fields at
runtime.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Declare memcpy_swahw32() as static

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Protect snd_pcm_stop() with snd_pcm_stream_lock_irq()

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Make hiface_pcm_playback() not returning anything

In hiface_pcm_playback() there is no need to return an error because the
format has alredy been checked by ALSA already.

Add a WARN_ON() to spot changes in upper layers if they happen in
future.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Move the period elapsed check into hiface_pcm_playback()

This simplifies the unlocking logic in the calling code.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Handle the case of failing URBs in hiface_pcm_out_urb_handler()

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>