/* Next the mux select. Both the "master" and "slave" 'cards' (controllers) use this routine. The routine finds the "master" for the card, maps the controller number from the detected position over to the logical number, writes the appropriate data to the analog switch, and housekeeps the local copy of the switch information. The parameter 'input' is the requested camera number (0 - 15).  */
static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input)
/* Next the mux select. Both the "master" and "slave" 'cards' (controllers) use this routine. The routine finds the "master" for the card, maps the controller number from the detected position over to the logical number, writes the appropriate data to the analog switch, and housekeeps the local copy of the switch information. The parameter 'input' is the requested camera number (0 - 15).  */
static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input)
{
	char *sw_status;
	int xaddr, yaddr;
	struct bttv *mctlr;
	static unsigned char map[4] = {3, 0, 2, 1};
	mctlr = master[btv->c.nr];
	if (mctlr == NULL) {
		return;
	}
	yaddr = (btv->c.nr - mctlr->c.nr + 1) & 3;
	yaddr = map[yaddr];
	sw_status = (char *)(&mctlr->mbox_we);
	xaddr = input & 0xf;
	if (sw_status[yaddr] != xaddr)
	{
		kodicom4400r_write(mctlr, sw_status[yaddr], yaddr, 0);
		sw_status[yaddr] = xaddr;
		kodicom4400r_write(mctlr, xaddr, yaddr, 1);
	}
}