diff mbox

[v3,3/4] stk1160: Add module param for setting the record gain.

Message ID 20161127111148.GA30483@arch-desktop (mailing list archive)
State New, archived
Headers show

Commit Message

Marcel Hasler Nov. 27, 2016, 11:11 a.m. UTC
Allow setting a custom record gain for the internal AC97 codec (if available). This can be
a value between 0 and 15, 8 is the default and should be suitable for most users. The Windows
driver also sets this to 8 without any possibility for changing it.

Signed-off-by: Marcel Hasler <mahasler@gmail.com>
---
 drivers/media/usb/stk1160/stk1160-ac97.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Mauro Carvalho Chehab Dec. 2, 2016, 11:05 a.m. UTC | #1
Em Sun, 27 Nov 2016 12:11:48 +0100
Marcel Hasler <mahasler@gmail.com> escreveu:

> Allow setting a custom record gain for the internal AC97 codec (if available). This can be
> a value between 0 and 15, 8 is the default and should be suitable for most users. The Windows
> driver also sets this to 8 without any possibility for changing it.

The problem of removing the mixer is that you need this kind of
crap to setup the volumes on a non-standard way.

NACK.

Instead, keep the alsa mixer. The way other drivers do (for example, 
em28xx) is that they configure the mixer when an input is selected,
increasing the volume of the active audio channel to 100% and muting
the other audio channels. Yet, as the alsa mixer is exported, users 
can change the mixer settings in runtime using some alsa (or pa)
mixer application.

> 
> Signed-off-by: Marcel Hasler <mahasler@gmail.com>
> ---
>  drivers/media/usb/stk1160/stk1160-ac97.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/stk1160/stk1160-ac97.c b/drivers/media/usb/stk1160/stk1160-ac97.c
> index 95648ac..60327af 100644
> --- a/drivers/media/usb/stk1160/stk1160-ac97.c
> +++ b/drivers/media/usb/stk1160/stk1160-ac97.c
> @@ -28,6 +28,11 @@
>  #include "stk1160.h"
>  #include "stk1160-reg.h"
>  
> +static u8 gain = 8;
> +
> +module_param(gain, byte, 0444);
> +MODULE_PARM_DESC(gain, "Set capture gain level if AC97 codec is available (0-15, default: 8)");
> +
>  static void stk1160_write_ac97(struct stk1160 *dev, u16 reg, u16 value)
>  {
>  	/* Set codec register address */
> @@ -136,7 +141,10 @@ void stk1160_ac97_setup(struct stk1160 *dev)
>  	stk1160_write_ac97(dev, 0x16, 0x0808); /* Aux volume */
>  	stk1160_write_ac97(dev, 0x1a, 0x0404); /* Record select */
>  	stk1160_write_ac97(dev, 0x02, 0x0000); /* Master volume */
> -	stk1160_write_ac97(dev, 0x1c, 0x0808); /* Record gain */
> +
> +	/* Record gain */
> +	gain = (gain > 15) ? 15 : gain;
> +	stk1160_write_ac97(dev, 0x1c, (gain<<8) | gain);
>  
>  #ifdef DEBUG
>  	stk1160_ac97_dump_regs(dev);



Thanks,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ezequiel Garcia Dec. 3, 2016, 8:46 p.m. UTC | #2
On 2 December 2016 at 08:05, Mauro Carvalho Chehab
<mchehab@s-opensource.com> wrote:
> Em Sun, 27 Nov 2016 12:11:48 +0100
> Marcel Hasler <mahasler@gmail.com> escreveu:
>
>> Allow setting a custom record gain for the internal AC97 codec (if available). This can be
>> a value between 0 and 15, 8 is the default and should be suitable for most users. The Windows
>> driver also sets this to 8 without any possibility for changing it.
>
> The problem of removing the mixer is that you need this kind of
> crap to setup the volumes on a non-standard way.
>

Right, that's a good point.

> NACK.
>
> Instead, keep the alsa mixer. The way other drivers do (for example,
> em28xx) is that they configure the mixer when an input is selected,
> increasing the volume of the active audio channel to 100% and muting
> the other audio channels. Yet, as the alsa mixer is exported, users
> can change the mixer settings in runtime using some alsa (or pa)
> mixer application.
>

Yeah, the AC97 mixer we are currently leveraging
exposes many controls that have no meaning in this device,
so removing that still looks like an improvement.

I guess the proper way is creating our own mixer
(not using snd_ac97_mixer)  exposing only the record
gain knob.

Marcel, what do you think?
Marcel Hasler Dec. 4, 2016, 1:01 p.m. UTC | #3
Hello

2016-12-03 21:46 GMT+01:00 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>:
> On 2 December 2016 at 08:05, Mauro Carvalho Chehab
> <mchehab@s-opensource.com> wrote:
>> Em Sun, 27 Nov 2016 12:11:48 +0100
>> Marcel Hasler <mahasler@gmail.com> escreveu:
>>
>>> Allow setting a custom record gain for the internal AC97 codec (if available). This can be
>>> a value between 0 and 15, 8 is the default and should be suitable for most users. The Windows
>>> driver also sets this to 8 without any possibility for changing it.
>>
>> The problem of removing the mixer is that you need this kind of
>> crap to setup the volumes on a non-standard way.
>>
>
> Right, that's a good point.
>
>> NACK.
>>
>> Instead, keep the alsa mixer. The way other drivers do (for example,
>> em28xx) is that they configure the mixer when an input is selected,
>> increasing the volume of the active audio channel to 100% and muting
>> the other audio channels. Yet, as the alsa mixer is exported, users
>> can change the mixer settings in runtime using some alsa (or pa)
>> mixer application.
>>
>
> Yeah, the AC97 mixer we are currently leveraging
> exposes many controls that have no meaning in this device,
> so removing that still looks like an improvement.
>
> I guess the proper way is creating our own mixer
> (not using snd_ac97_mixer)  exposing only the record
> gain knob.
>
> Marcel, what do you think?
> --
> Ezequiel García, VanguardiaSur
> www.vanguardiasur.com.ar

As I have written before, the recording gain isn't actually meant to
be changed by the user. In the official Windows driver this value is
hard-coded to 8 and cannot be changed in any way. And there really is
no good reason why anyone should need to mess with it in the first
place. The default value will give the best results in pretty much all
cases and produces approximately the same volume as the internal 8-bit
ADC whose gain cannot be changed at all, not even by a driver.

I had considered writing a mixer but chose not to. If the gain setting
is openly exposed to mixer applications, how do you tell the users
that the value set by the driver already is the optimal and
recommended value and that they shouldn't mess with the controls
unless they really have to? By having a module parameter, this setting
is practically hidden from the normal user but still is available to
power-users if they think they really need it. In the end it's really
just a compromise between hiding it completely and exposing it openly.
Also, this way the driver guarantees reproducible results, since
there's no need to remember the positions of any volume sliders.

Either way, if you still think this solution is "crap", feel free to
modify the patches in any way you see fit. I've wasted too much time
on this already, and since I'm not being paid for it, I don't intend
to put any more effort into this.

Best regards
Marcel
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ezequiel Garcia Dec. 4, 2016, 6:25 p.m. UTC | #4
On 4 December 2016 at 10:01, Marcel Hasler <mahasler@gmail.com> wrote:
> Hello
>
> 2016-12-03 21:46 GMT+01:00 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>:
>> On 2 December 2016 at 08:05, Mauro Carvalho Chehab
>> <mchehab@s-opensource.com> wrote:
>>> Em Sun, 27 Nov 2016 12:11:48 +0100
>>> Marcel Hasler <mahasler@gmail.com> escreveu:
>>>
>>>> Allow setting a custom record gain for the internal AC97 codec (if available). This can be
>>>> a value between 0 and 15, 8 is the default and should be suitable for most users. The Windows
>>>> driver also sets this to 8 without any possibility for changing it.
>>>
>>> The problem of removing the mixer is that you need this kind of
>>> crap to setup the volumes on a non-standard way.
>>>
>>
>> Right, that's a good point.
>>
>>> NACK.
>>>
>>> Instead, keep the alsa mixer. The way other drivers do (for example,
>>> em28xx) is that they configure the mixer when an input is selected,
>>> increasing the volume of the active audio channel to 100% and muting
>>> the other audio channels. Yet, as the alsa mixer is exported, users
>>> can change the mixer settings in runtime using some alsa (or pa)
>>> mixer application.
>>>
>>
>> Yeah, the AC97 mixer we are currently leveraging
>> exposes many controls that have no meaning in this device,
>> so removing that still looks like an improvement.
>>
>> I guess the proper way is creating our own mixer
>> (not using snd_ac97_mixer)  exposing only the record
>> gain knob.
>>
>> Marcel, what do you think?
>> --
>> Ezequiel García, VanguardiaSur
>> www.vanguardiasur.com.ar
>
> As I have written before, the recording gain isn't actually meant to
> be changed by the user. In the official Windows driver this value is
> hard-coded to 8 and cannot be changed in any way. And there really is
> no good reason why anyone should need to mess with it in the first
> place. The default value will give the best results in pretty much all
> cases and produces approximately the same volume as the internal 8-bit
> ADC whose gain cannot be changed at all, not even by a driver.
>
> I had considered writing a mixer but chose not to. If the gain setting
> is openly exposed to mixer applications, how do you tell the users
> that the value set by the driver already is the optimal and
> recommended value and that they shouldn't mess with the controls
> unless they really have to? By having a module parameter, this setting
> is practically hidden from the normal user but still is available to
> power-users if they think they really need it. In the end it's really
> just a compromise between hiding it completely and exposing it openly.
> Also, this way the driver guarantees reproducible results, since
> there's no need to remember the positions of any volume sliders.
>

Hm, right. I've never changed the record gain, and it's true that it
doens't really improve the volume. So, I would be OK with having
a module parameter.

On the other side, we are exposing it currently, through the "Capture"
mixer control:

Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 15
  Front Left: Capture 10 [67%] [15.00dB] [on]
  Front Right: Capture 8 [53%] [12.00dB] [on]

So, it would be user-friendly to keep the user interface and continue
to expose the same knob - even if the default is the optimal, etc.

To be completely honest, I don't think any user is really relying
on any REC_GAIN / Capture setting, and I'm completely OK
with having a mixer control or a module parameter. It doesn't matter.

What matters here, is getting rid of the stupid AC97 mixer,
with a dozen of playback and capture controls that have no meaning
whatsoever.

> Either way, if you still think this solution is "crap", feel free to
> modify the patches in any way you see fit. I've wasted too much time
> on this already, and since I'm not being paid for it, I don't intend
> to put any more effort into this.
>

FWIW, I don't think your patches are crap. Quite the opposite,
it's refreshing to see such good stuff being submitted.

After the click noise you fixed in snd-usb-audio, removing the mixer
is the last TODO thing in this driver. So I really appreciate all the time
you have put in it.
Mauro Carvalho Chehab Dec. 5, 2016, 12:12 p.m. UTC | #5
Em Sun, 4 Dec 2016 15:25:25 -0300
Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> escreveu:

> On 4 December 2016 at 10:01, Marcel Hasler <mahasler@gmail.com> wrote:
> > Hello
> >
> > 2016-12-03 21:46 GMT+01:00 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>:  
> >> On 2 December 2016 at 08:05, Mauro Carvalho Chehab
> >> <mchehab@s-opensource.com> wrote:  
> >>> Em Sun, 27 Nov 2016 12:11:48 +0100
> >>> Marcel Hasler <mahasler@gmail.com> escreveu:
> >>>  
> >>>> Allow setting a custom record gain for the internal AC97 codec (if available). This can be
> >>>> a value between 0 and 15, 8 is the default and should be suitable for most users. The Windows
> >>>> driver also sets this to 8 without any possibility for changing it.  
> >>>
> >>> The problem of removing the mixer is that you need this kind of
> >>> crap to setup the volumes on a non-standard way.
> >>>  
> >>
> >> Right, that's a good point.
> >>  
> >>> NACK.
> >>>
> >>> Instead, keep the alsa mixer. The way other drivers do (for example,
> >>> em28xx) is that they configure the mixer when an input is selected,
> >>> increasing the volume of the active audio channel to 100% and muting
> >>> the other audio channels. Yet, as the alsa mixer is exported, users
> >>> can change the mixer settings in runtime using some alsa (or pa)
> >>> mixer application.
> >>>  
> >>
> >> Yeah, the AC97 mixer we are currently leveraging
> >> exposes many controls that have no meaning in this device,
> >> so removing that still looks like an improvement.
> >>
> >> I guess the proper way is creating our own mixer
> >> (not using snd_ac97_mixer)  exposing only the record
> >> gain knob.
> >>
> >> Marcel, what do you think?
> >> --
> >> Ezequiel García, VanguardiaSur
> >> www.vanguardiasur.com.ar  
> >
> > As I have written before, the recording gain isn't actually meant to
> > be changed by the user. In the official Windows driver this value is
> > hard-coded to 8 and cannot be changed in any way. And there really is
> > no good reason why anyone should need to mess with it in the first
> > place. The default value will give the best results in pretty much all
> > cases and produces approximately the same volume as the internal 8-bit
> > ADC whose gain cannot be changed at all, not even by a driver.
> >
> > I had considered writing a mixer but chose not to. If the gain setting
> > is openly exposed to mixer applications, how do you tell the users
> > that the value set by the driver already is the optimal and
> > recommended value and that they shouldn't mess with the controls
> > unless they really have to? By having a module parameter, this setting
> > is practically hidden from the normal user but still is available to
> > power-users if they think they really need it. In the end it's really
> > just a compromise between hiding it completely and exposing it openly.
> > Also, this way the driver guarantees reproducible results, since
> > there's no need to remember the positions of any volume sliders.
> >  
> 
> Hm, right. I've never changed the record gain, and it's true that it
> doens't really improve the volume. So, I would be OK with having
> a module parameter.
> 
> On the other side, we are exposing it currently, through the "Capture"
> mixer control:
> 
> Simple mixer control 'Capture',0
>   Capabilities: cvolume cswitch cswitch-joined
>   Capture channels: Front Left - Front Right
>   Limits: Capture 0 - 15
>   Front Left: Capture 10 [67%] [15.00dB] [on]
>   Front Right: Capture 8 [53%] [12.00dB] [on]
> 
> So, it would be user-friendly to keep the user interface and continue
> to expose the same knob - even if the default is the optimal, etc.
> 
> To be completely honest, I don't think any user is really relying
> on any REC_GAIN / Capture setting, and I'm completely OK
> with having a mixer control or a module parameter. It doesn't matter.

If you're positive that *all* stk1160 use the ac97 mixer the
same way, and that there's no sense on having a mixer for it,
then it would be ok to remove it.

In such case, then why you need a modprobe parameter to allow
setting the record level? If this mixer entry is not used,
just set it to zero and be happy with that.

Regards,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ezequiel Garcia Dec. 5, 2016, 3:38 p.m. UTC | #6
On 5 December 2016 at 09:12, Mauro Carvalho Chehab
<mchehab@s-opensource.com> wrote:
> Em Sun, 4 Dec 2016 15:25:25 -0300
> Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> escreveu:
>
>> On 4 December 2016 at 10:01, Marcel Hasler <mahasler@gmail.com> wrote:
>> > Hello
>> >
>> > 2016-12-03 21:46 GMT+01:00 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>:
>> >> On 2 December 2016 at 08:05, Mauro Carvalho Chehab
>> >> <mchehab@s-opensource.com> wrote:
>> >>> Em Sun, 27 Nov 2016 12:11:48 +0100
>> >>> Marcel Hasler <mahasler@gmail.com> escreveu:
>> >>>
>> >>>> Allow setting a custom record gain for the internal AC97 codec (if available). This can be
>> >>>> a value between 0 and 15, 8 is the default and should be suitable for most users. The Windows
>> >>>> driver also sets this to 8 without any possibility for changing it.
>> >>>
>> >>> The problem of removing the mixer is that you need this kind of
>> >>> crap to setup the volumes on a non-standard way.
>> >>>
>> >>
>> >> Right, that's a good point.
>> >>
>> >>> NACK.
>> >>>
>> >>> Instead, keep the alsa mixer. The way other drivers do (for example,
>> >>> em28xx) is that they configure the mixer when an input is selected,
>> >>> increasing the volume of the active audio channel to 100% and muting
>> >>> the other audio channels. Yet, as the alsa mixer is exported, users
>> >>> can change the mixer settings in runtime using some alsa (or pa)
>> >>> mixer application.
>> >>>
>> >>
>> >> Yeah, the AC97 mixer we are currently leveraging
>> >> exposes many controls that have no meaning in this device,
>> >> so removing that still looks like an improvement.
>> >>
>> >> I guess the proper way is creating our own mixer
>> >> (not using snd_ac97_mixer)  exposing only the record
>> >> gain knob.
>> >>
>> >> Marcel, what do you think?
>> >> --
>> >> Ezequiel García, VanguardiaSur
>> >> www.vanguardiasur.com.ar
>> >
>> > As I have written before, the recording gain isn't actually meant to
>> > be changed by the user. In the official Windows driver this value is
>> > hard-coded to 8 and cannot be changed in any way. And there really is
>> > no good reason why anyone should need to mess with it in the first
>> > place. The default value will give the best results in pretty much all
>> > cases and produces approximately the same volume as the internal 8-bit
>> > ADC whose gain cannot be changed at all, not even by a driver.
>> >
>> > I had considered writing a mixer but chose not to. If the gain setting
>> > is openly exposed to mixer applications, how do you tell the users
>> > that the value set by the driver already is the optimal and
>> > recommended value and that they shouldn't mess with the controls
>> > unless they really have to? By having a module parameter, this setting
>> > is practically hidden from the normal user but still is available to
>> > power-users if they think they really need it. In the end it's really
>> > just a compromise between hiding it completely and exposing it openly.
>> > Also, this way the driver guarantees reproducible results, since
>> > there's no need to remember the positions of any volume sliders.
>> >
>>
>> Hm, right. I've never changed the record gain, and it's true that it
>> doens't really improve the volume. So, I would be OK with having
>> a module parameter.
>>
>> On the other side, we are exposing it currently, through the "Capture"
>> mixer control:
>>
>> Simple mixer control 'Capture',0
>>   Capabilities: cvolume cswitch cswitch-joined
>>   Capture channels: Front Left - Front Right
>>   Limits: Capture 0 - 15
>>   Front Left: Capture 10 [67%] [15.00dB] [on]
>>   Front Right: Capture 8 [53%] [12.00dB] [on]
>>
>> So, it would be user-friendly to keep the user interface and continue
>> to expose the same knob - even if the default is the optimal, etc.
>>
>> To be completely honest, I don't think any user is really relying
>> on any REC_GAIN / Capture setting, and I'm completely OK
>> with having a mixer control or a module parameter. It doesn't matter.
>
> If you're positive that *all* stk1160 use the ac97 mixer the
> same way, and that there's no sense on having a mixer for it,
> then it would be ok to remove it.
>

Let's remove it then!

> In such case, then why you need a modprobe parameter to allow
> setting the record level? If this mixer entry is not used,
> just set it to zero and be happy with that.
>

Let's remove the module param too, then.

Thanks,
Marcel Hasler Dec. 5, 2016, 9:06 p.m. UTC | #7
Hello

2016-12-05 16:38 GMT+01:00 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>:
> On 5 December 2016 at 09:12, Mauro Carvalho Chehab
> <mchehab@s-opensource.com> wrote:
>> Em Sun, 4 Dec 2016 15:25:25 -0300
>> Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> escreveu:
>>
>>> On 4 December 2016 at 10:01, Marcel Hasler <mahasler@gmail.com> wrote:
>>> > Hello
>>> >
>>> > 2016-12-03 21:46 GMT+01:00 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>:
>>> >> On 2 December 2016 at 08:05, Mauro Carvalho Chehab
>>> >> <mchehab@s-opensource.com> wrote:
>>> >>> Em Sun, 27 Nov 2016 12:11:48 +0100
>>> >>> Marcel Hasler <mahasler@gmail.com> escreveu:
>>> >>>
>>> >>>> Allow setting a custom record gain for the internal AC97 codec (if available). This can be
>>> >>>> a value between 0 and 15, 8 is the default and should be suitable for most users. The Windows
>>> >>>> driver also sets this to 8 without any possibility for changing it.
>>> >>>
>>> >>> The problem of removing the mixer is that you need this kind of
>>> >>> crap to setup the volumes on a non-standard way.
>>> >>>
>>> >>
>>> >> Right, that's a good point.
>>> >>
>>> >>> NACK.
>>> >>>
>>> >>> Instead, keep the alsa mixer. The way other drivers do (for example,
>>> >>> em28xx) is that they configure the mixer when an input is selected,
>>> >>> increasing the volume of the active audio channel to 100% and muting
>>> >>> the other audio channels. Yet, as the alsa mixer is exported, users
>>> >>> can change the mixer settings in runtime using some alsa (or pa)
>>> >>> mixer application.
>>> >>>
>>> >>
>>> >> Yeah, the AC97 mixer we are currently leveraging
>>> >> exposes many controls that have no meaning in this device,
>>> >> so removing that still looks like an improvement.
>>> >>
>>> >> I guess the proper way is creating our own mixer
>>> >> (not using snd_ac97_mixer)  exposing only the record
>>> >> gain knob.
>>> >>
>>> >> Marcel, what do you think?
>>> >> --
>>> >> Ezequiel García, VanguardiaSur
>>> >> www.vanguardiasur.com.ar
>>> >
>>> > As I have written before, the recording gain isn't actually meant to
>>> > be changed by the user. In the official Windows driver this value is
>>> > hard-coded to 8 and cannot be changed in any way. And there really is
>>> > no good reason why anyone should need to mess with it in the first
>>> > place. The default value will give the best results in pretty much all
>>> > cases and produces approximately the same volume as the internal 8-bit
>>> > ADC whose gain cannot be changed at all, not even by a driver.
>>> >
>>> > I had considered writing a mixer but chose not to. If the gain setting
>>> > is openly exposed to mixer applications, how do you tell the users
>>> > that the value set by the driver already is the optimal and
>>> > recommended value and that they shouldn't mess with the controls
>>> > unless they really have to? By having a module parameter, this setting
>>> > is practically hidden from the normal user but still is available to
>>> > power-users if they think they really need it. In the end it's really
>>> > just a compromise between hiding it completely and exposing it openly.
>>> > Also, this way the driver guarantees reproducible results, since
>>> > there's no need to remember the positions of any volume sliders.
>>> >
>>>
>>> Hm, right. I've never changed the record gain, and it's true that it
>>> doens't really improve the volume. So, I would be OK with having
>>> a module parameter.
>>>
>>> On the other side, we are exposing it currently, through the "Capture"
>>> mixer control:
>>>
>>> Simple mixer control 'Capture',0
>>>   Capabilities: cvolume cswitch cswitch-joined
>>>   Capture channels: Front Left - Front Right
>>>   Limits: Capture 0 - 15
>>>   Front Left: Capture 10 [67%] [15.00dB] [on]
>>>   Front Right: Capture 8 [53%] [12.00dB] [on]
>>>
>>> So, it would be user-friendly to keep the user interface and continue
>>> to expose the same knob - even if the default is the optimal, etc.
>>>
>>> To be completely honest, I don't think any user is really relying
>>> on any REC_GAIN / Capture setting, and I'm completely OK
>>> with having a mixer control or a module parameter. It doesn't matter.
>>
>> If you're positive that *all* stk1160 use the ac97 mixer the
>> same way, and that there's no sense on having a mixer for it,
>> then it would be ok to remove it.
>>
>
> Let's remove it then!
>
>> In such case, then why you need a modprobe parameter to allow
>> setting the record level? If this mixer entry is not used,
>> just set it to zero and be happy with that.
>>
>
> Let's remove the module param too, then.

I'm okay with that.

>
> Thanks,
> --
> Ezequiel García, VanguardiaSur
> www.vanguardiasur.com.ar

I'm willing to prepare one final patchset, provided we can agree on
and resolve all issues beforehand.

So far the changes would be to remove the module param and to poll
STK1160_AC97CTL_0 instead of using a fixed delay. It's probably better
to also poll it before writing, although that never caused problems.

I'll post some code for review before actually submitting patches.
Mauro, is there anything else that you think should be changed? If so,
please tell me now. Thanks.

Best regards
Marcel
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcel Hasler Dec. 5, 2016, 9:18 p.m. UTC | #8
2016-12-05 22:06 GMT+01:00 Marcel Hasler <mahasler@gmail.com>:
> Hello
>
> 2016-12-05 16:38 GMT+01:00 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>:
>> On 5 December 2016 at 09:12, Mauro Carvalho Chehab
>> <mchehab@s-opensource.com> wrote:
>>> Em Sun, 4 Dec 2016 15:25:25 -0300
>>> Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> escreveu:
>>>
>>>> On 4 December 2016 at 10:01, Marcel Hasler <mahasler@gmail.com> wrote:
>>>> > Hello
>>>> >
>>>> > 2016-12-03 21:46 GMT+01:00 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>:
>>>> >> On 2 December 2016 at 08:05, Mauro Carvalho Chehab
>>>> >> <mchehab@s-opensource.com> wrote:
>>>> >>> Em Sun, 27 Nov 2016 12:11:48 +0100
>>>> >>> Marcel Hasler <mahasler@gmail.com> escreveu:
>>>> >>>
>>>> >>>> Allow setting a custom record gain for the internal AC97 codec (if available). This can be
>>>> >>>> a value between 0 and 15, 8 is the default and should be suitable for most users. The Windows
>>>> >>>> driver also sets this to 8 without any possibility for changing it.
>>>> >>>
>>>> >>> The problem of removing the mixer is that you need this kind of
>>>> >>> crap to setup the volumes on a non-standard way.
>>>> >>>
>>>> >>
>>>> >> Right, that's a good point.
>>>> >>
>>>> >>> NACK.
>>>> >>>
>>>> >>> Instead, keep the alsa mixer. The way other drivers do (for example,
>>>> >>> em28xx) is that they configure the mixer when an input is selected,
>>>> >>> increasing the volume of the active audio channel to 100% and muting
>>>> >>> the other audio channels. Yet, as the alsa mixer is exported, users
>>>> >>> can change the mixer settings in runtime using some alsa (or pa)
>>>> >>> mixer application.
>>>> >>>
>>>> >>
>>>> >> Yeah, the AC97 mixer we are currently leveraging
>>>> >> exposes many controls that have no meaning in this device,
>>>> >> so removing that still looks like an improvement.
>>>> >>
>>>> >> I guess the proper way is creating our own mixer
>>>> >> (not using snd_ac97_mixer)  exposing only the record
>>>> >> gain knob.
>>>> >>
>>>> >> Marcel, what do you think?
>>>> >> --
>>>> >> Ezequiel García, VanguardiaSur
>>>> >> www.vanguardiasur.com.ar
>>>> >
>>>> > As I have written before, the recording gain isn't actually meant to
>>>> > be changed by the user. In the official Windows driver this value is
>>>> > hard-coded to 8 and cannot be changed in any way. And there really is
>>>> > no good reason why anyone should need to mess with it in the first
>>>> > place. The default value will give the best results in pretty much all
>>>> > cases and produces approximately the same volume as the internal 8-bit
>>>> > ADC whose gain cannot be changed at all, not even by a driver.
>>>> >
>>>> > I had considered writing a mixer but chose not to. If the gain setting
>>>> > is openly exposed to mixer applications, how do you tell the users
>>>> > that the value set by the driver already is the optimal and
>>>> > recommended value and that they shouldn't mess with the controls
>>>> > unless they really have to? By having a module parameter, this setting
>>>> > is practically hidden from the normal user but still is available to
>>>> > power-users if they think they really need it. In the end it's really
>>>> > just a compromise between hiding it completely and exposing it openly.
>>>> > Also, this way the driver guarantees reproducible results, since
>>>> > there's no need to remember the positions of any volume sliders.
>>>> >
>>>>
>>>> Hm, right. I've never changed the record gain, and it's true that it
>>>> doens't really improve the volume. So, I would be OK with having
>>>> a module parameter.
>>>>
>>>> On the other side, we are exposing it currently, through the "Capture"
>>>> mixer control:
>>>>
>>>> Simple mixer control 'Capture',0
>>>>   Capabilities: cvolume cswitch cswitch-joined
>>>>   Capture channels: Front Left - Front Right
>>>>   Limits: Capture 0 - 15
>>>>   Front Left: Capture 10 [67%] [15.00dB] [on]
>>>>   Front Right: Capture 8 [53%] [12.00dB] [on]
>>>>
>>>> So, it would be user-friendly to keep the user interface and continue
>>>> to expose the same knob - even if the default is the optimal, etc.
>>>>
>>>> To be completely honest, I don't think any user is really relying
>>>> on any REC_GAIN / Capture setting, and I'm completely OK
>>>> with having a mixer control or a module parameter. It doesn't matter.
>>>
>>> If you're positive that *all* stk1160 use the ac97 mixer the
>>> same way, and that there's no sense on having a mixer for it,
>>> then it would be ok to remove it.
>>>
>>
>> Let's remove it then!
>>
>>> In such case, then why you need a modprobe parameter to allow
>>> setting the record level? If this mixer entry is not used,
>>> just set it to zero and be happy with that.
>>>
>>
>> Let's remove the module param too, then.
>
> I'm okay with that.
>
>>
>> Thanks,
>> --
>> Ezequiel García, VanguardiaSur
>> www.vanguardiasur.com.ar
>
> I'm willing to prepare one final patchset, provided we can agree on
> and resolve all issues beforehand.
>
> So far the changes would be to remove the module param and to poll
> STK1160_AC97CTL_0 instead of using a fixed delay. It's probably better
> to also poll it before writing, although that never caused problems.
>
> I'll post some code for review before actually submitting patches.
> Mauro, is there anything else that you think should be changed? If so,
> please tell me now. Thanks.
>
> Best regards
> Marcel

One more thing...

The driver currently uses a lot of "magic numbers", both for the AC97
register addresses as well as the STK1160 register contents. That
makes it a bit difficult to read unless you happen to have the
datasheet open. Would it maybe be better to add defines for those,
especially if we're going to poll individual bits? I usually prefer
that approach myself. Would you put the defines for the AC97 chip
registers into stk1160-reg.h or keep them in stk1160-ac97.c since
they're only used there?

Best regards
Marcel
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ezequiel Garcia Dec. 5, 2016, 10:34 p.m. UTC | #9
On 5 December 2016 at 18:06, Marcel Hasler <mahasler@gmail.com> wrote:
> Hello
>
> 2016-12-05 16:38 GMT+01:00 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>:
>> On 5 December 2016 at 09:12, Mauro Carvalho Chehab
>> <mchehab@s-opensource.com> wrote:
>>> Em Sun, 4 Dec 2016 15:25:25 -0300
>>> Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> escreveu:
>>>
>>>> On 4 December 2016 at 10:01, Marcel Hasler <mahasler@gmail.com> wrote:
>>>> > Hello
>>>> >
>>>> > 2016-12-03 21:46 GMT+01:00 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>:
>>>> >> On 2 December 2016 at 08:05, Mauro Carvalho Chehab
>>>> >> <mchehab@s-opensource.com> wrote:
>>>> >>> Em Sun, 27 Nov 2016 12:11:48 +0100
>>>> >>> Marcel Hasler <mahasler@gmail.com> escreveu:
>>>> >>>
>>>> >>>> Allow setting a custom record gain for the internal AC97 codec (if available). This can be
>>>> >>>> a value between 0 and 15, 8 is the default and should be suitable for most users. The Windows
>>>> >>>> driver also sets this to 8 without any possibility for changing it.
>>>> >>>
>>>> >>> The problem of removing the mixer is that you need this kind of
>>>> >>> crap to setup the volumes on a non-standard way.
>>>> >>>
>>>> >>
>>>> >> Right, that's a good point.
>>>> >>
>>>> >>> NACK.
>>>> >>>
>>>> >>> Instead, keep the alsa mixer. The way other drivers do (for example,
>>>> >>> em28xx) is that they configure the mixer when an input is selected,
>>>> >>> increasing the volume of the active audio channel to 100% and muting
>>>> >>> the other audio channels. Yet, as the alsa mixer is exported, users
>>>> >>> can change the mixer settings in runtime using some alsa (or pa)
>>>> >>> mixer application.
>>>> >>>
>>>> >>
>>>> >> Yeah, the AC97 mixer we are currently leveraging
>>>> >> exposes many controls that have no meaning in this device,
>>>> >> so removing that still looks like an improvement.
>>>> >>
>>>> >> I guess the proper way is creating our own mixer
>>>> >> (not using snd_ac97_mixer)  exposing only the record
>>>> >> gain knob.
>>>> >>
>>>> >> Marcel, what do you think?
>>>> >> --
>>>> >> Ezequiel García, VanguardiaSur
>>>> >> www.vanguardiasur.com.ar
>>>> >
>>>> > As I have written before, the recording gain isn't actually meant to
>>>> > be changed by the user. In the official Windows driver this value is
>>>> > hard-coded to 8 and cannot be changed in any way. And there really is
>>>> > no good reason why anyone should need to mess with it in the first
>>>> > place. The default value will give the best results in pretty much all
>>>> > cases and produces approximately the same volume as the internal 8-bit
>>>> > ADC whose gain cannot be changed at all, not even by a driver.
>>>> >
>>>> > I had considered writing a mixer but chose not to. If the gain setting
>>>> > is openly exposed to mixer applications, how do you tell the users
>>>> > that the value set by the driver already is the optimal and
>>>> > recommended value and that they shouldn't mess with the controls
>>>> > unless they really have to? By having a module parameter, this setting
>>>> > is practically hidden from the normal user but still is available to
>>>> > power-users if they think they really need it. In the end it's really
>>>> > just a compromise between hiding it completely and exposing it openly.
>>>> > Also, this way the driver guarantees reproducible results, since
>>>> > there's no need to remember the positions of any volume sliders.
>>>> >
>>>>
>>>> Hm, right. I've never changed the record gain, and it's true that it
>>>> doens't really improve the volume. So, I would be OK with having
>>>> a module parameter.
>>>>
>>>> On the other side, we are exposing it currently, through the "Capture"
>>>> mixer control:
>>>>
>>>> Simple mixer control 'Capture',0
>>>>   Capabilities: cvolume cswitch cswitch-joined
>>>>   Capture channels: Front Left - Front Right
>>>>   Limits: Capture 0 - 15
>>>>   Front Left: Capture 10 [67%] [15.00dB] [on]
>>>>   Front Right: Capture 8 [53%] [12.00dB] [on]
>>>>
>>>> So, it would be user-friendly to keep the user interface and continue
>>>> to expose the same knob - even if the default is the optimal, etc.
>>>>
>>>> To be completely honest, I don't think any user is really relying
>>>> on any REC_GAIN / Capture setting, and I'm completely OK
>>>> with having a mixer control or a module parameter. It doesn't matter.
>>>
>>> If you're positive that *all* stk1160 use the ac97 mixer the
>>> same way, and that there's no sense on having a mixer for it,
>>> then it would be ok to remove it.
>>>
>>
>> Let's remove it then!
>>
>>> In such case, then why you need a modprobe parameter to allow
>>> setting the record level? If this mixer entry is not used,
>>> just set it to zero and be happy with that.
>>>
>>
>> Let's remove the module param too, then.
>
> I'm okay with that.
>
>>
>> Thanks,
>> --
>> Ezequiel García, VanguardiaSur
>> www.vanguardiasur.com.ar
>
> I'm willing to prepare one final patchset, provided we can agree on
> and resolve all issues beforehand.
>
> So far the changes would be to remove the module param and to poll
> STK1160_AC97CTL_0 instead of using a fixed delay. It's probably better
> to also poll it before writing, although that never caused problems.
>

If that's too much trouble or too much of a hassle,
imaybe just remove the read_reg. It's not really
used right now, except for dumping the registers.
Ezequiel Garcia Dec. 5, 2016, 10:35 p.m. UTC | #10
On 5 December 2016 at 18:18, Marcel Hasler <mahasler@gmail.com> wrote:
> 2016-12-05 22:06 GMT+01:00 Marcel Hasler <mahasler@gmail.com>:
>> Hello
>>
>> 2016-12-05 16:38 GMT+01:00 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>:
>>> On 5 December 2016 at 09:12, Mauro Carvalho Chehab
>>> <mchehab@s-opensource.com> wrote:
>>>> Em Sun, 4 Dec 2016 15:25:25 -0300
>>>> Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> escreveu:
>>>>
>>>>> On 4 December 2016 at 10:01, Marcel Hasler <mahasler@gmail.com> wrote:
>>>>> > Hello
>>>>> >
>>>>> > 2016-12-03 21:46 GMT+01:00 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>:
>>>>> >> On 2 December 2016 at 08:05, Mauro Carvalho Chehab
>>>>> >> <mchehab@s-opensource.com> wrote:
>>>>> >>> Em Sun, 27 Nov 2016 12:11:48 +0100
>>>>> >>> Marcel Hasler <mahasler@gmail.com> escreveu:
>>>>> >>>
>>>>> >>>> Allow setting a custom record gain for the internal AC97 codec (if available). This can be
>>>>> >>>> a value between 0 and 15, 8 is the default and should be suitable for most users. The Windows
>>>>> >>>> driver also sets this to 8 without any possibility for changing it.
>>>>> >>>
>>>>> >>> The problem of removing the mixer is that you need this kind of
>>>>> >>> crap to setup the volumes on a non-standard way.
>>>>> >>>
>>>>> >>
>>>>> >> Right, that's a good point.
>>>>> >>
>>>>> >>> NACK.
>>>>> >>>
>>>>> >>> Instead, keep the alsa mixer. The way other drivers do (for example,
>>>>> >>> em28xx) is that they configure the mixer when an input is selected,
>>>>> >>> increasing the volume of the active audio channel to 100% and muting
>>>>> >>> the other audio channels. Yet, as the alsa mixer is exported, users
>>>>> >>> can change the mixer settings in runtime using some alsa (or pa)
>>>>> >>> mixer application.
>>>>> >>>
>>>>> >>
>>>>> >> Yeah, the AC97 mixer we are currently leveraging
>>>>> >> exposes many controls that have no meaning in this device,
>>>>> >> so removing that still looks like an improvement.
>>>>> >>
>>>>> >> I guess the proper way is creating our own mixer
>>>>> >> (not using snd_ac97_mixer)  exposing only the record
>>>>> >> gain knob.
>>>>> >>
>>>>> >> Marcel, what do you think?
>>>>> >> --
>>>>> >> Ezequiel García, VanguardiaSur
>>>>> >> www.vanguardiasur.com.ar
>>>>> >
>>>>> > As I have written before, the recording gain isn't actually meant to
>>>>> > be changed by the user. In the official Windows driver this value is
>>>>> > hard-coded to 8 and cannot be changed in any way. And there really is
>>>>> > no good reason why anyone should need to mess with it in the first
>>>>> > place. The default value will give the best results in pretty much all
>>>>> > cases and produces approximately the same volume as the internal 8-bit
>>>>> > ADC whose gain cannot be changed at all, not even by a driver.
>>>>> >
>>>>> > I had considered writing a mixer but chose not to. If the gain setting
>>>>> > is openly exposed to mixer applications, how do you tell the users
>>>>> > that the value set by the driver already is the optimal and
>>>>> > recommended value and that they shouldn't mess with the controls
>>>>> > unless they really have to? By having a module parameter, this setting
>>>>> > is practically hidden from the normal user but still is available to
>>>>> > power-users if they think they really need it. In the end it's really
>>>>> > just a compromise between hiding it completely and exposing it openly.
>>>>> > Also, this way the driver guarantees reproducible results, since
>>>>> > there's no need to remember the positions of any volume sliders.
>>>>> >
>>>>>
>>>>> Hm, right. I've never changed the record gain, and it's true that it
>>>>> doens't really improve the volume. So, I would be OK with having
>>>>> a module parameter.
>>>>>
>>>>> On the other side, we are exposing it currently, through the "Capture"
>>>>> mixer control:
>>>>>
>>>>> Simple mixer control 'Capture',0
>>>>>   Capabilities: cvolume cswitch cswitch-joined
>>>>>   Capture channels: Front Left - Front Right
>>>>>   Limits: Capture 0 - 15
>>>>>   Front Left: Capture 10 [67%] [15.00dB] [on]
>>>>>   Front Right: Capture 8 [53%] [12.00dB] [on]
>>>>>
>>>>> So, it would be user-friendly to keep the user interface and continue
>>>>> to expose the same knob - even if the default is the optimal, etc.
>>>>>
>>>>> To be completely honest, I don't think any user is really relying
>>>>> on any REC_GAIN / Capture setting, and I'm completely OK
>>>>> with having a mixer control or a module parameter. It doesn't matter.
>>>>
>>>> If you're positive that *all* stk1160 use the ac97 mixer the
>>>> same way, and that there's no sense on having a mixer for it,
>>>> then it would be ok to remove it.
>>>>
>>>
>>> Let's remove it then!
>>>
>>>> In such case, then why you need a modprobe parameter to allow
>>>> setting the record level? If this mixer entry is not used,
>>>> just set it to zero and be happy with that.
>>>>
>>>
>>> Let's remove the module param too, then.
>>
>> I'm okay with that.
>>
>>>
>>> Thanks,
>>> --
>>> Ezequiel García, VanguardiaSur
>>> www.vanguardiasur.com.ar
>>
>> I'm willing to prepare one final patchset, provided we can agree on
>> and resolve all issues beforehand.
>>
>> So far the changes would be to remove the module param and to poll
>> STK1160_AC97CTL_0 instead of using a fixed delay. It's probably better
>> to also poll it before writing, although that never caused problems.
>>
>> I'll post some code for review before actually submitting patches.
>> Mauro, is there anything else that you think should be changed? If so,
>> please tell me now. Thanks.
>>
>> Best regards
>> Marcel
>
> One more thing...
>
> The driver currently uses a lot of "magic numbers", both for the AC97
> register addresses as well as the STK1160 register contents. That
> makes it a bit difficult to read unless you happen to have the
> datasheet open. Would it maybe be better to add defines for those,
> especially if we're going to poll individual bits?

Yes, but we don't want to put that on the same series.
Let's this out first, and then we can work on more changes.

> I usually prefer
> that approach myself. Would you put the defines for the AC97 chip
> registers into stk1160-reg.h or keep them in stk1160-ac97.c since
> they're only used there?
>

I'm fine either way. For consistency with how it's written currently,
I'd go with stk1160-reg.h
Mauro Carvalho Chehab Dec. 6, 2016, 12:56 p.m. UTC | #11
Em Mon, 5 Dec 2016 22:06:59 +0100
Marcel Hasler <mahasler@gmail.com> escreveu:

> Hello
> 
> 2016-12-05 16:38 GMT+01:00 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>:
> > On 5 December 2016 at 09:12, Mauro Carvalho Chehab
> > <mchehab@s-opensource.com> wrote:  
> >> Em Sun, 4 Dec 2016 15:25:25 -0300
> >> Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> escreveu:
> >>  
> >>> On 4 December 2016 at 10:01, Marcel Hasler <mahasler@gmail.com> wrote:  
> >>> > Hello
> >>> >
> >>> > 2016-12-03 21:46 GMT+01:00 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>:  
> >>> >> On 2 December 2016 at 08:05, Mauro Carvalho Chehab
> >>> >> <mchehab@s-opensource.com> wrote:  
> >>> >>> Em Sun, 27 Nov 2016 12:11:48 +0100
> >>> >>> Marcel Hasler <mahasler@gmail.com> escreveu:
> >>> >>>  
> >>> >>>> Allow setting a custom record gain for the internal AC97 codec (if available). This can be
> >>> >>>> a value between 0 and 15, 8 is the default and should be suitable for most users. The Windows
> >>> >>>> driver also sets this to 8 without any possibility for changing it.  
> >>> >>>
> >>> >>> The problem of removing the mixer is that you need this kind of
> >>> >>> crap to setup the volumes on a non-standard way.
> >>> >>>  
> >>> >>
> >>> >> Right, that's a good point.
> >>> >>  
> >>> >>> NACK.
> >>> >>>
> >>> >>> Instead, keep the alsa mixer. The way other drivers do (for example,
> >>> >>> em28xx) is that they configure the mixer when an input is selected,
> >>> >>> increasing the volume of the active audio channel to 100% and muting
> >>> >>> the other audio channels. Yet, as the alsa mixer is exported, users
> >>> >>> can change the mixer settings in runtime using some alsa (or pa)
> >>> >>> mixer application.
> >>> >>>  
> >>> >>
> >>> >> Yeah, the AC97 mixer we are currently leveraging
> >>> >> exposes many controls that have no meaning in this device,
> >>> >> so removing that still looks like an improvement.
> >>> >>
> >>> >> I guess the proper way is creating our own mixer
> >>> >> (not using snd_ac97_mixer)  exposing only the record
> >>> >> gain knob.
> >>> >>
> >>> >> Marcel, what do you think?
> >>> >> --
> >>> >> Ezequiel García, VanguardiaSur
> >>> >> www.vanguardiasur.com.ar  
> >>> >
> >>> > As I have written before, the recording gain isn't actually meant to
> >>> > be changed by the user. In the official Windows driver this value is
> >>> > hard-coded to 8 and cannot be changed in any way. And there really is
> >>> > no good reason why anyone should need to mess with it in the first
> >>> > place. The default value will give the best results in pretty much all
> >>> > cases and produces approximately the same volume as the internal 8-bit
> >>> > ADC whose gain cannot be changed at all, not even by a driver.
> >>> >
> >>> > I had considered writing a mixer but chose not to. If the gain setting
> >>> > is openly exposed to mixer applications, how do you tell the users
> >>> > that the value set by the driver already is the optimal and
> >>> > recommended value and that they shouldn't mess with the controls
> >>> > unless they really have to? By having a module parameter, this setting
> >>> > is practically hidden from the normal user but still is available to
> >>> > power-users if they think they really need it. In the end it's really
> >>> > just a compromise between hiding it completely and exposing it openly.
> >>> > Also, this way the driver guarantees reproducible results, since
> >>> > there's no need to remember the positions of any volume sliders.
> >>> >  
> >>>
> >>> Hm, right. I've never changed the record gain, and it's true that it
> >>> doens't really improve the volume. So, I would be OK with having
> >>> a module parameter.
> >>>
> >>> On the other side, we are exposing it currently, through the "Capture"
> >>> mixer control:
> >>>
> >>> Simple mixer control 'Capture',0
> >>>   Capabilities: cvolume cswitch cswitch-joined
> >>>   Capture channels: Front Left - Front Right
> >>>   Limits: Capture 0 - 15
> >>>   Front Left: Capture 10 [67%] [15.00dB] [on]
> >>>   Front Right: Capture 8 [53%] [12.00dB] [on]
> >>>
> >>> So, it would be user-friendly to keep the user interface and continue
> >>> to expose the same knob - even if the default is the optimal, etc.
> >>>
> >>> To be completely honest, I don't think any user is really relying
> >>> on any REC_GAIN / Capture setting, and I'm completely OK
> >>> with having a mixer control or a module parameter. It doesn't matter.  
> >>
> >> If you're positive that *all* stk1160 use the ac97 mixer the
> >> same way, and that there's no sense on having a mixer for it,
> >> then it would be ok to remove it.
> >>  
> >
> > Let's remove it then!
> >  
> >> In such case, then why you need a modprobe parameter to allow
> >> setting the record level? If this mixer entry is not used,
> >> just set it to zero and be happy with that.
> >>  
> >
> > Let's remove the module param too, then.  
> 
> I'm okay with that.
> 
> >
> > Thanks,
> > --
> > Ezequiel García, VanguardiaSur
> > www.vanguardiasur.com.ar  
> 
> I'm willing to prepare one final patchset, provided we can agree on
> and resolve all issues beforehand.
> 
> So far the changes would be to remove the module param and to poll
> STK1160_AC97CTL_0 instead of using a fixed delay. It's probably better
> to also poll it before writing, although that never caused problems.

Sounds ok. My experience with AC97 on em28xx is that, as new devices
were added, the delay needed for AC97 varied on some of those new
devices. That's why checking if AC97 is ready before writing was
added to its code.

> 
> I'll post some code for review before actually submitting patches.
> Mauro, is there anything else that you think should be changed? If so,
> please tell me now. Thanks.
> 
> Best regards
> Marcel



Thanks,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/usb/stk1160/stk1160-ac97.c b/drivers/media/usb/stk1160/stk1160-ac97.c
index 95648ac..60327af 100644
--- a/drivers/media/usb/stk1160/stk1160-ac97.c
+++ b/drivers/media/usb/stk1160/stk1160-ac97.c
@@ -28,6 +28,11 @@ 
 #include "stk1160.h"
 #include "stk1160-reg.h"
 
+static u8 gain = 8;
+
+module_param(gain, byte, 0444);
+MODULE_PARM_DESC(gain, "Set capture gain level if AC97 codec is available (0-15, default: 8)");
+
 static void stk1160_write_ac97(struct stk1160 *dev, u16 reg, u16 value)
 {
 	/* Set codec register address */
@@ -136,7 +141,10 @@  void stk1160_ac97_setup(struct stk1160 *dev)
 	stk1160_write_ac97(dev, 0x16, 0x0808); /* Aux volume */
 	stk1160_write_ac97(dev, 0x1a, 0x0404); /* Record select */
 	stk1160_write_ac97(dev, 0x02, 0x0000); /* Master volume */
-	stk1160_write_ac97(dev, 0x1c, 0x0808); /* Record gain */
+
+	/* Record gain */
+	gain = (gain > 15) ? 15 : gain;
+	stk1160_write_ac97(dev, 0x1c, (gain<<8) | gain);
 
 #ifdef DEBUG
 	stk1160_ac97_dump_regs(dev);