Subject: Re: HEADS UP: dev/pci/auixp (IXP-200 audio support) in progress
To: None <>
From: Reinoud Zandijk <>
List: tech-kern
Date: 12/27/2004 17:11:33
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hiya Kent,

On Sat, Dec 25, 2004 at 09:51:51PM +0900, TAMURA Kent wrote:
> In message "Re: HEADS UP: dev/pci/auixp (IXP-200 audio support) in progress"
>     on 04/12/24, Reinoud Zandijk <> writes:
> > > > 	ac97_attach(struct ac97_host_if host_if *, struct device *)
> > > 
> > > Why is it needed?  You can pass a pointer to struct device as
> > > host_if.arg.
> > 
> > true indeed! but the question is: why is it _mandatory_ to do so? The 
> > reason i am not passing my struct device * in host_if.arg is to support 
> > multiple codec attachments.?On the ATI-IXP chip i need to know the codec 
> > number to write to; therefore i create a small structure with the nessisary 
> > codec number embedded in it. Or is this allready there somewhere or is it a 
> > non-issue?
> I guess you wnat to change host methods from
> 	foo_read(void *host_if_arg, uint8_t, uint16_t *)
> to
> 	foo_read(struct device *d, void *host_if_arg, uint8_t, uint16_t *).
> Right?

not really... looking at the ac97 code, i found that only ac97_attach() 
*assumes* that host_if->arg starts with the device structure. It only uses 
this host_if->arg as a device to pretty-print its device name when 
attaching :

ac97_attach(struct ac97_host_if *host_if)
	struct ac97_softc *as;
	struct device *sc_dev;

	sc_dev = (struct device *)host_if->arg;
	initfunc = NULL;

all other usages of host_if->arg are used to call the functions in the 
host_if structure and are therefore semantically OK and host_if->arg is 
thus indeed a void *.

The few places ac97_attach is using this derived sc_dev is in functions 
calls like :

	aprint_normal("%s: ac97: ", sc_dev->dv_xname);

> I think multiple-codec support can be done in a driver with the
> current API.  yds(4) seems to handle three codecs.  ICH can also
> have three codecs though auich(4) does not support multiple
> codecs and I have never seen such boards.

yds indeed uses the same technique as i do; with the small API change i 
hereby propose, the hidden demand that the host_if->arg needs to be 
starting/derived from a struct device* can go.

The only change i'd like to propose is a change from :

int ac97_attach(struct ac97_host_if *host_if);


int ac97_attach(struct ac97_host_if *host_if, struct device *sc_dev);

All the rest remains the same. Current implementations that are using the 
assumption that the host_if->arg indeed needs to start with a struct device 
are not affected by it since the host_if->arg then indeed is opaque to the 
ac97 code.


P.S. your last message gave a bad pgp key!

Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.2.6 (NetBSD)