Commit df243fe2 authored by HardenedBSD Sync Service's avatar HardenedBSD Sync Service
Browse files

Merge branch 'freebsd/current/main' into hardened/current/master

parents 2f59f0bc 39844001
......@@ -77,13 +77,13 @@ mixer_open(const char *name)
if (name != NULL) {
/* `name` does not start with "/dev/mixer". */
if (strncmp(name, BASEPATH, strlen(BASEPATH)) != 0) {
errno = EINVAL;
goto fail;
m->unit = -1;
} else {
/* `name` is "/dev/mixer" so, we'll use the default unit. */
if (strncmp(name, BASEPATH, strlen(name)) == 0)
goto dunit;
m->unit = strtol(name + strlen(BASEPATH), NULL, 10);
}
/* `name` is "/dev/mixer" so, we'll use the default unit. */
if (strncmp(name, BASEPATH, strlen(name)) == 0)
goto dunit;
m->unit = strtol(name + strlen(BASEPATH), NULL, 10);
(void)strlcpy(m->name, name, sizeof(m->name));
} else {
dunit:
......@@ -101,9 +101,13 @@ mixer_open(const char *name)
/* The unit number _must_ be set before the ioctl. */
m->mi.dev = m->unit;
m->ci.card = m->unit;
if (ioctl(m->fd, SNDCTL_MIXERINFO, &m->mi) < 0 ||
ioctl(m->fd, SNDCTL_CARDINFO, &m->ci) < 0 ||
ioctl(m->fd, SOUND_MIXER_READ_DEVMASK, &m->devmask) < 0 ||
if (ioctl(m->fd, SNDCTL_MIXERINFO, &m->mi) < 0) {
memset(&m->mi, 0, sizeof(m->mi));
strlcpy(m->mi.name, m->name, sizeof(m->mi.name));
}
if (ioctl(m->fd, SNDCTL_CARDINFO, &m->ci) < 0)
memset(&m->ci, 0, sizeof(m->ci));
if (ioctl(m->fd, SOUND_MIXER_READ_DEVMASK, &m->devmask) < 0 ||
ioctl(m->fd, SOUND_MIXER_READ_MUTE, &m->mutemask) < 0 ||
ioctl(m->fd, SOUND_MIXER_READ_RECMASK, &m->recmask) < 0 ||
ioctl(m->fd, SOUND_MIXER_READ_RECSRC, &m->recsrc) < 0)
......@@ -463,7 +467,7 @@ mixer_get_mode(int unit)
(void)snprintf(buf, sizeof(buf), "dev.pcm.%d.mode", unit);
size = sizeof(unsigned int);
if (sysctlbyname(buf, &mode, &size, NULL, 0) < 0)
return (-1);
return (0);
return (mode);
}
......
......@@ -1495,7 +1495,7 @@ t4fw.fwo optional cxgbe \
no-implicit-rule \
clean "t4fw.fwo"
t4fw.fw optional cxgbe \
dependency "$S/dev/cxgbe/firmware/t4fw-1.26.0.0.bin" \
dependency "$S/dev/cxgbe/firmware/t4fw-1.26.2.0.bin" \
compile-with "${CP} ${.ALLSRC} ${.TARGET}" \
no-obj no-implicit-rule \
clean "t4fw.fw"
......@@ -1529,7 +1529,7 @@ t5fw.fwo optional cxgbe \
no-implicit-rule \
clean "t5fw.fwo"
t5fw.fw optional cxgbe \
dependency "$S/dev/cxgbe/firmware/t5fw-1.26.0.0.bin" \
dependency "$S/dev/cxgbe/firmware/t5fw-1.26.2.0.bin" \
compile-with "${CP} ${.ALLSRC} ${.TARGET}" \
no-obj no-implicit-rule \
clean "t5fw.fw"
......@@ -1563,7 +1563,7 @@ t6fw.fwo optional cxgbe \
no-implicit-rule \
clean "t6fw.fwo"
t6fw.fw optional cxgbe \
dependency "$S/dev/cxgbe/firmware/t6fw-1.26.0.0.bin" \
dependency "$S/dev/cxgbe/firmware/t6fw-1.26.2.0.bin" \
compile-with "${CP} ${.ALLSRC} ${.TARGET}" \
no-obj no-implicit-rule \
clean "t6fw.fw"
......
......@@ -9952,7 +9952,10 @@ struct fw_hdr {
__u32 reserved3;
__be32 magic; /* runtime or bootstrap fw */
__be32 flags;
__be32 reserved6[23];
__be32 reserved6[4];
__u8 reserved7[3];
__u8 dsign_len;
__u8 dsign[72]; /* fw binary digital signature */
};
enum fw_hdr_chip {
......@@ -9992,17 +9995,17 @@ enum fw_hdr_chip {
enum {
T4FW_VERSION_MAJOR = 1,
T4FW_VERSION_MINOR = 26,
T4FW_VERSION_MICRO = 0,
T4FW_VERSION_MICRO = 2,
T4FW_VERSION_BUILD = 0,
T5FW_VERSION_MAJOR = 1,
T5FW_VERSION_MINOR = 26,
T5FW_VERSION_MICRO = 0,
T5FW_VERSION_MICRO = 2,
T5FW_VERSION_BUILD = 0,
T6FW_VERSION_MAJOR = 1,
T6FW_VERSION_MINOR = 26,
T6FW_VERSION_MICRO = 0,
T6FW_VERSION_MICRO = 2,
T6FW_VERSION_BUILD = 0,
};
......@@ -10052,6 +10055,7 @@ enum {
enum fw_hdr_flags {
FW_HDR_FLAGS_RESET_HALT = 0x00000001,
FW_HDR_FLAGS_SIGNED_FW = 0x00000002,
};
/*
......
......@@ -1223,6 +1223,8 @@ chn_init(struct pcm_channel *c, void *devinfo, int dir, int direction)
c->volume[SND_VOL_C_MASTER][SND_CHN_T_VOL_0DB] = SND_VOL_0DB_MASTER;
c->volume[SND_VOL_C_PCM][SND_CHN_T_VOL_0DB] = chn_vol_0db_pcm;
memset(c->muted, 0, sizeof(c->muted));
chn_vpc_reset(c, SND_VOL_C_PCM, 1);
ret = ENODEV;
......@@ -1394,6 +1396,75 @@ chn_getvolume_matrix(struct pcm_channel *c, int vc, int vt)
return (c->volume[vc][vt]);
}
int
chn_setmute_multi(struct pcm_channel *c, int vc, int mute)
{
int i, ret;
ret = 0;
for (i = 0; i < SND_CHN_T_MAX; i++) {
if ((1 << i) & SND_CHN_LEFT_MASK)
ret |= chn_setmute_matrix(c, vc, i, mute);
else if ((1 << i) & SND_CHN_RIGHT_MASK)
ret |= chn_setmute_matrix(c, vc, i, mute) << 8;
else
ret |= chn_setmute_matrix(c, vc, i, mute) << 16;
}
return (ret);
}
int
chn_setmute_matrix(struct pcm_channel *c, int vc, int vt, int mute)
{
int i;
KASSERT(c != NULL && vc >= SND_VOL_C_MASTER && vc < SND_VOL_C_MAX &&
(vc == SND_VOL_C_MASTER || (vc & 1)) &&
(vt == SND_CHN_T_VOL_0DB || (vt >= SND_CHN_T_BEGIN && vt <= SND_CHN_T_END)),
("%s(): invalid mute matrix c=%p vc=%d vt=%d mute=%d",
__func__, c, vc, vt, mute));
CHN_LOCKASSERT(c);
mute = (mute != 0);
c->muted[vc][vt] = mute;
/*
* Do relative calculation here and store it into class + 1
* to ease the job of feeder_volume.
*/
if (vc == SND_VOL_C_MASTER) {
for (vc = SND_VOL_C_BEGIN; vc <= SND_VOL_C_END;
vc += SND_VOL_C_STEP)
c->muted[SND_VOL_C_VAL(vc)][vt] = mute;
} else if (vc & 1) {
if (vt == SND_CHN_T_VOL_0DB) {
for (i = SND_CHN_T_BEGIN; i <= SND_CHN_T_END;
i += SND_CHN_T_STEP) {
c->muted[SND_VOL_C_VAL(vc)][i] = mute;
}
} else {
c->muted[SND_VOL_C_VAL(vc)][vt] = mute;
}
}
return (mute);
}
int
chn_getmute_matrix(struct pcm_channel *c, int vc, int vt)
{
KASSERT(c != NULL && vc >= SND_VOL_C_MASTER && vc < SND_VOL_C_MAX &&
(vt == SND_CHN_T_VOL_0DB ||
(vt >= SND_CHN_T_BEGIN && vt <= SND_CHN_T_END)),
("%s(): invalid mute matrix c=%p vc=%d vt=%d",
__func__, c, vc, vt));
CHN_LOCKASSERT(c);
return (c->muted[vc][vt]);
}
struct pcmchan_matrix *
chn_getmatrix(struct pcm_channel *c)
{
......
......@@ -166,7 +166,8 @@ struct pcm_channel {
struct pcmchan_matrix matrix;
struct pcmchan_matrix matrix_scratch;
int volume[SND_VOL_C_MAX][SND_CHN_T_VOL_MAX];
int16_t volume[SND_VOL_C_MAX][SND_CHN_T_VOL_MAX];
int8_t muted[SND_VOL_C_MAX][SND_CHN_T_VOL_MAX];
void *data1, *data2;
};
......@@ -271,6 +272,9 @@ int chn_setvolume_multi(struct pcm_channel *c, int vc, int left, int right,
int center);
int chn_setvolume_matrix(struct pcm_channel *c, int vc, int vt, int val);
int chn_getvolume_matrix(struct pcm_channel *c, int vc, int vt);
int chn_setmute_multi(struct pcm_channel *c, int vc, int mute);
int chn_setmute_matrix(struct pcm_channel *c, int vc, int vt, int mute);
int chn_getmute_matrix(struct pcm_channel *c, int vc, int vt);
void chn_vpc_reset(struct pcm_channel *c, int vc, int force);
int chn_setparam(struct pcm_channel *c, uint32_t format, uint32_t speed);
int chn_setspeed(struct pcm_channel *c, uint32_t speed);
......@@ -307,6 +311,8 @@ int chn_syncdestroy(struct pcm_channel *c);
#define CHN_GETVOLUME(x, y, z) ((x)->volume[y][z])
#endif
#define CHN_GETMUTE(x, y, z) ((x)->muted[y][z])
#ifdef OSSV4_EXPERIMENT
int chn_getpeaks(struct pcm_channel *c, int *lpeak, int *rpeak);
#endif
......
......@@ -960,6 +960,7 @@ dsp_ioctl_channel(struct cdev *dev, struct pcm_channel *volch, u_long cmd,
struct snddev_info *d;
struct pcm_channel *rdch, *wrch;
int j, devtype, ret;
int left, right, center, mute;
d = dsp_get_info(dev);
if (!PCM_REGISTERED(d) || !(dsp_get_flags(dev) & SD_F_VPC))
......@@ -998,67 +999,95 @@ dsp_ioctl_channel(struct cdev *dev, struct pcm_channel *volch, u_long cmd,
}
/* Final validation */
if (volch != NULL) {
CHN_LOCK(volch);
if (!(volch->feederflags & (1 << FEEDER_VOLUME))) {
CHN_UNLOCK(volch);
return (-1);
}
if (volch->direction == PCMDIR_PLAY)
wrch = volch;
else
rdch = volch;
}
ret = EINVAL;
if (volch == NULL)
return (EINVAL);
if (volch != NULL &&
((j == SOUND_MIXER_PCM && volch->direction == PCMDIR_PLAY) ||
(j == SOUND_MIXER_RECLEV && volch->direction == PCMDIR_REC))) {
if ((cmd & ~0xff) == MIXER_WRITE(0)) {
int left, right, center;
CHN_LOCK(volch);
if (!(volch->feederflags & (1 << FEEDER_VOLUME))) {
CHN_UNLOCK(volch);
return (EINVAL);
}
switch (cmd & ~0xff) {
case MIXER_WRITE(0):
switch (j) {
case SOUND_MIXER_MUTE:
if (volch->direction == PCMDIR_REC) {
chn_setmute_multi(volch, SND_VOL_C_PCM, (*(int *)arg & SOUND_MASK_RECLEV) != 0);
} else {
chn_setmute_multi(volch, SND_VOL_C_PCM, (*(int *)arg & SOUND_MASK_PCM) != 0);
}
break;
case SOUND_MIXER_PCM:
if (volch->direction != PCMDIR_PLAY)
break;
left = *(int *)arg & 0x7f;
right = ((*(int *)arg) >> 8) & 0x7f;
center = (left + right) >> 1;
chn_setvolume_multi(volch, SND_VOL_C_PCM, left, right,
center);
} else if ((cmd & ~0xff) == MIXER_READ(0)) {
*(int *)arg = CHN_GETVOLUME(volch,
SND_VOL_C_PCM, SND_CHN_T_FL);
*(int *)arg |= CHN_GETVOLUME(volch,
SND_VOL_C_PCM, SND_CHN_T_FR) << 8;
chn_setvolume_multi(volch, SND_VOL_C_PCM,
left, right, center);
break;
case SOUND_MIXER_RECLEV:
if (volch->direction != PCMDIR_REC)
break;
left = *(int *)arg & 0x7f;
right = ((*(int *)arg) >> 8) & 0x7f;
center = (left + right) >> 1;
chn_setvolume_multi(volch, SND_VOL_C_PCM,
left, right, center);
break;
default:
/* ignore all other mixer writes */
break;
}
ret = 0;
} else if (rdch != NULL || wrch != NULL) {
break;
case MIXER_READ(0):
switch (j) {
case SOUND_MIXER_MUTE:
mute = CHN_GETMUTE(volch, SND_VOL_C_PCM, SND_CHN_T_FL) ||
CHN_GETMUTE(volch, SND_VOL_C_PCM, SND_CHN_T_FR);
if (volch->direction == PCMDIR_REC) {
*(int *)arg = mute << SOUND_MIXER_RECLEV;
} else {
*(int *)arg = mute << SOUND_MIXER_PCM;
}
break;
case SOUND_MIXER_PCM:
if (volch->direction != PCMDIR_PLAY)
break;
*(int *)arg = CHN_GETVOLUME(volch,
SND_VOL_C_PCM, SND_CHN_T_FL);
*(int *)arg |= CHN_GETVOLUME(volch,
SND_VOL_C_PCM, SND_CHN_T_FR) << 8;
break;
case SOUND_MIXER_RECLEV:
if (volch->direction != PCMDIR_REC)
break;
*(int *)arg = CHN_GETVOLUME(volch,
SND_VOL_C_PCM, SND_CHN_T_FL);
*(int *)arg |= CHN_GETVOLUME(volch,
SND_VOL_C_PCM, SND_CHN_T_FR) << 8;
break;
case SOUND_MIXER_DEVMASK:
case SOUND_MIXER_CAPS:
case SOUND_MIXER_STEREODEVS:
if ((cmd & ~0xff) == MIXER_READ(0)) {
*(int *)arg = 0;
if (rdch != NULL)
*(int *)arg |= SOUND_MASK_RECLEV;
if (wrch != NULL)
*(int *)arg |= SOUND_MASK_PCM;
}
ret = 0;
break;
case SOUND_MIXER_RECMASK:
case SOUND_MIXER_RECSRC:
if ((cmd & ~0xff) == MIXER_READ(0))
*(int *)arg = 0;
ret = 0;
if (volch->direction == PCMDIR_REC)
*(int *)arg = SOUND_MASK_RECLEV;
else
*(int *)arg = SOUND_MASK_PCM;
break;
default:
*(int *)arg = 0;
break;
}
}
if (volch != NULL)
CHN_UNLOCK(volch);
break;
return (ret);
default:
break;
}
CHN_UNLOCK(volch);
return (0);
}
static int
......
......@@ -237,10 +237,13 @@ static int
feed_volume_feed(struct pcm_feeder *f, struct pcm_channel *c, uint8_t *b,
uint32_t count, void *source)
{
int temp_vol[SND_CHN_T_VOL_MAX];
struct feed_volume_info *info;
uint32_t j, align;
int i, *vol, *matrix;
int i, *matrix;
uint8_t *dst;
const int16_t *vol;
const int8_t *muted;
/*
* Fetch filter data operation.
......@@ -251,6 +254,7 @@ feed_volume_feed(struct pcm_feeder *f, struct pcm_channel *c, uint8_t *b,
return (FEEDER_FEED(f->source, c, b, count, source));
vol = c->volume[SND_VOL_C_VAL(info->volume_class)];
muted = c->muted[SND_VOL_C_VAL(info->volume_class)];
matrix = info->matrix;
/*
......@@ -258,17 +262,22 @@ feed_volume_feed(struct pcm_feeder *f, struct pcm_channel *c, uint8_t *b,
*/
j = 0;
i = info->channels;
do {
if (vol[matrix[--i]] != SND_VOL_FLAT) {
while (i--) {
if (vol[matrix[i]] != SND_VOL_FLAT ||
muted[matrix[i]] != 0) {
j = 1;
break;
}
} while (i != 0);
}
/* Nope, just bypass entirely. */
if (j == 0)
return (FEEDER_FEED(f->source, c, b, count, source));
/* Check if any controls are muted. */
for (j = 0; j != SND_CHN_T_VOL_MAX; j++)
temp_vol[j] = muted[j] ? 0 : vol[j];
dst = b;
align = info->bps * info->channels;
......@@ -281,7 +290,7 @@ feed_volume_feed(struct pcm_feeder *f, struct pcm_channel *c, uint8_t *b,
if (j == 0)
break;
info->apply(vol, matrix, info->channels, dst, j);
info->apply(temp_vol, matrix, info->channels, dst, j);
j *= align;
dst += j;
......
......@@ -17,7 +17,7 @@ FIRMWS+= ${F}:${F:C/.txt//}:1.0.0.0
.endif
.endfor
T4FW_VER= 1.26.0.0
T4FW_VER= 1.26.2.0
FIRMWS+= t4fw-${T4FW_VER}.bin:t4fw:${T4FW_VER}
.include <bsd.kmod.mk>
......@@ -17,7 +17,7 @@ FIRMWS+= ${F}:${F:C/.txt//}:1.0.0.0
.endif
.endfor
T5FW_VER= 1.26.0.0
T5FW_VER= 1.26.2.0
FIRMWS+= t5fw-${T5FW_VER}.bin:t5fw:${T5FW_VER}
.include <bsd.kmod.mk>
......@@ -17,7 +17,7 @@ FIRMWS+= ${F}:${F:C/.txt//}:1.0.0.0
.endif
.endfor
T6FW_VER= 1.26.0.0
T6FW_VER= 1.26.2.0
FIRMWS+= t6fw-${T6FW_VER}.bin:t6fw:${T6FW_VER}
.include <bsd.kmod.mk>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment