/* ad1843_get_gain reads the specified register and extracts the gain value using the supplied gain type.  */
int ad1843_get_gain(struct snd_ad1843 *ad1843, int id)
/* ad1843_get_gain reads the specified register and extracts the gain value using the supplied gain type.  */
int ad1843_get_gain(struct snd_ad1843 *ad1843, int id)
{
	int lg, rg, lm, rm;
	const struct ad1843_gain *gp = ad1843_gain[id];
	unsigned short mask = (1 << gp->lfield->nbits) - 1;
	ad1843_read_multi(ad1843, 2, gp->lfield, &lg, gp->rfield, &rg);
	if (gp->negative) {
		lg = mask - lg;
		rg = mask - rg;
	}
	if (gp->lmute) {
		ad1843_read_multi(ad1843, 2, gp->lmute, &lm, gp->rmute, &rm);
		if (lm)
			lg = 0;
		if (rm)
			rg = 0;
	}
	return lg << 0 | rg << 8;
}