Subject: Re: HEADS UP: dev/pci/auixp (IXP-200 audio support) in progress
To: None <tech-kern@netbsd.org>
From: Reinoud Zandijk <reinoud@netbsd.org>
List: tech-kern
Date: 12/27/2004 17:11:33
--6TrnltStXW4iwmi0
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 <reinoud@netbsd.org> 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 :

int
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);

to

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.

Cheers,
Reinoud

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

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (NetBSD)

iQEVAwUBQdA0J4KcNwBDyKpoAQLjnwf+IRcUCc7wgcq5Ub8+DSleELWb6AdcsRfd
ibdg4AcQFV/jPDzwBIyNNBE77E1F9qEWycNQxbCWkvQymlVgfCSRW6AhiuUVaw8t
WsugV0c2LkmPQCojCcmIMKW72LvHOgHABtfZDnnP7QjFcrdw2USD5YOAXQvj+s6M
wqQF0fKvaPf18sGhYFTetAonuD4zl6VnB/DJ86SuWz28ghyBT5IoeMFkRGkxSlb5
8XxpksHbxTSClY5uaq/SwRmUb3EgbOxlX5DJc0pDCaUzjMUfEBRgJar4szSAHKTs
en+TNXEpIV+xA0jtHHZrFHQBEyluV2GO+u2oLQraRvbJU0Mb/FXnmw==
=dVYD
-----END PGP SIGNATURE-----

--6TrnltStXW4iwmi0--