From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.suse.de (ns.suse.de [195.135.220.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx1.suse.de", Issuer "Thawte Premium Server CA" (verified OK)) by ozlabs.org (Postfix) with ESMTP id 69B5967B18 for ; Tue, 30 May 2006 23:19:47 +1000 (EST) Date: Tue, 30 May 2006 15:19:41 +0200 Message-ID: From: Takashi Iwai To: Johannes Berg Subject: Re: [Alsa-devel] [RFC 4/7] snd-aoa: add codecs In-Reply-To: <1148992996.3102.8.camel@johannes> References: <20060528190026.754474000@johannes.berg> <20060528190125.927852000@johannes.berg> <1148992996.3102.8.camel@johannes> MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: linuxppc-dev@ozlabs.org, alsa-devel@alsa-project.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , At Tue, 30 May 2006 14:43:16 +0200, Johannes Berg wrote: > > On Mon, 2006-05-29 at 14:08 +0200, Takashi Iwai wrote: > > > + if (reg != ONYX_REG_CONTROL) { > > > + *value = onyx->cache[reg-FIRSTREGISTER]; > > > + return 0; > > > + } > > > + v = i2c_smbus_read_byte_data(&onyx->i2c, reg); > > > + if (v < 0) > > > + return -1; > > > + *value = (u8)v; > > > + onyx->cache[ONYX_REG_CONTROL-FIRSTREGISTER] = *value; > > > > Isn't it "reg - FIRSTREGISTER" ? > > Nah, look at the first line I quoted :) Ah, OK it's anyway same... > > > + /* FIXME: we could be checking if anything changed */ > > > + mutex_unlock(&onyx->mutex); > > > + > > > + return 1; > > > > The put callback is supposed to return 0 if the values are unchanged > > (although most apps ignore the return value). > > Does it have to? This way there's an event, but... Yes, in principle. As mentioned, it works even without the check, though. > > > +static int tas_snd_capture_source_info(struct snd_kcontrol *kcontrol, > > > + struct snd_ctl_elem_info *uinfo) > > > +{ > > > + static char* texts[] = { "Line-In", "Microphone" }; > > > > char *texts[] > > Any particular reason? Well, I meant the position of asterisk to follow the conventional C coding style. Of course it should be static. > > > + aoa_snd_ctl_add(snd_ctl_new1(&volume_control, tas)); > > > > Error checks please. > > What should it do on such errors? The driver should give up the initialization and fail to load. Usually the error from snd_ctl_add() is critical, either no memory or a duplicated control element is found. Takashi From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [RFC 4/7] snd-aoa: add codecs Date: Tue, 30 May 2006 15:19:41 +0200 Message-ID: References: <20060528190026.754474000@johannes.berg> <20060528190125.927852000@johannes.berg> <1148992996.3102.8.camel@johannes> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (ns.suse.de [195.135.220.2]) by alsa.jcu.cz (ALSA's E-mail Delivery System) with ESMTP id 5F86D10C for ; Tue, 30 May 2006 15:19:42 +0200 (MEST) In-Reply-To: <1148992996.3102.8.camel@johannes> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@lists.sourceforge.net Errors-To: alsa-devel-bounces@lists.sourceforge.net To: Johannes Berg Cc: linuxppc-dev@ozlabs.org, alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Tue, 30 May 2006 14:43:16 +0200, Johannes Berg wrote: > > On Mon, 2006-05-29 at 14:08 +0200, Takashi Iwai wrote: > > > + if (reg != ONYX_REG_CONTROL) { > > > + *value = onyx->cache[reg-FIRSTREGISTER]; > > > + return 0; > > > + } > > > + v = i2c_smbus_read_byte_data(&onyx->i2c, reg); > > > + if (v < 0) > > > + return -1; > > > + *value = (u8)v; > > > + onyx->cache[ONYX_REG_CONTROL-FIRSTREGISTER] = *value; > > > > Isn't it "reg - FIRSTREGISTER" ? > > Nah, look at the first line I quoted :) Ah, OK it's anyway same... > > > + /* FIXME: we could be checking if anything changed */ > > > + mutex_unlock(&onyx->mutex); > > > + > > > + return 1; > > > > The put callback is supposed to return 0 if the values are unchanged > > (although most apps ignore the return value). > > Does it have to? This way there's an event, but... Yes, in principle. As mentioned, it works even without the check, though. > > > +static int tas_snd_capture_source_info(struct snd_kcontrol *kcontrol, > > > + struct snd_ctl_elem_info *uinfo) > > > +{ > > > + static char* texts[] = { "Line-In", "Microphone" }; > > > > char *texts[] > > Any particular reason? Well, I meant the position of asterisk to follow the conventional C coding style. Of course it should be static. > > > + aoa_snd_ctl_add(snd_ctl_new1(&volume_control, tas)); > > > > Error checks please. > > What should it do on such errors? The driver should give up the initialization and fail to load. Usually the error from snd_ctl_add() is critical, either no memory or a duplicated control element is found. Takashi