From 9a0a1c68845bc88e1b7600d635f8dcda0c45f0dc Mon Sep 17 00:00:00 2001 From: netchild Date: Sun, 18 Jun 2006 14:14:41 +0000 Subject: [PATCH] - Rename hw.snd.unit to hw.snd.default_unit to make the purpose more obvious. - Enable 4 automatic vchan's by default. - Add some comments which provide ides/questions for improvement. - Prefix some temporary sysctl's with an underscore to denote that it is not an official API but a workaround until the real solution is implemented. --- sys/dev/sound/midi/midi.c | 1 + sys/dev/sound/midi/sequencer.c | 1 + sys/dev/sound/pci/cmi.c | 7 ++++++- sys/dev/sound/pci/es137x.c | 24 +++++++++++++++++++++--- sys/dev/sound/pci/ich.c | 3 +++ sys/dev/sound/pci/maestro.c | 3 +++ sys/dev/sound/pci/via8233.c | 8 ++++++-- sys/dev/sound/pcm/feeder_rate.c | 4 +++- sys/dev/sound/pcm/sound.c | 18 ++++++++++++------ sys/dev/sound/pcm/vchan.c | 7 +++++-- 10 files changed, 61 insertions(+), 15 deletions(-) diff --git a/sys/dev/sound/midi/midi.c b/sys/dev/sound/midi/midi.c index 4bb4646ba3c2..36daf5faf657 100644 --- a/sys/dev/sound/midi/midi.c +++ b/sys/dev/sound/midi/midi.c @@ -244,6 +244,7 @@ SYSCTL_NODE(_hw, OID_AUTO, midi, CTLFLAG_RD, 0, "Midi driver"); SYSCTL_NODE(_hw_midi, OID_AUTO, stat, CTLFLAG_RD, 0, "Status device"); int midi_debug; +/* XXX: should this be moved into debug.midi? */ SYSCTL_INT(_hw_midi, OID_AUTO, debug, CTLFLAG_RW, &midi_debug, 0, ""); int midi_dumpraw; diff --git a/sys/dev/sound/midi/sequencer.c b/sys/dev/sound/midi/sequencer.c index 87319f7339ec..b179492979ac 100644 --- a/sys/dev/sound/midi/sequencer.c +++ b/sys/dev/sound/midi/sequencer.c @@ -153,6 +153,7 @@ struct seq_softc { SYSCTL_NODE(_hw_midi, OID_AUTO, seq, CTLFLAG_RD, 0, "Midi sequencer"); int seq_debug; +/* XXX: should this be moved into debug.midi? */ SYSCTL_INT(_hw_midi_seq, OID_AUTO, debug, CTLFLAG_RW, &seq_debug, 0, ""); midi_cmdtab cmdtab_seqevent[] = { diff --git a/sys/dev/sound/pci/cmi.c b/sys/dev/sound/pci/cmi.c index 41fa7385ebae..b2ddb5626486 100644 --- a/sys/dev/sound/pci/cmi.c +++ b/sys/dev/sound/pci/cmi.c @@ -741,9 +741,14 @@ static int cmi_initsys(struct sc_info* sc) { #ifdef SND_DYNSYSCTL + /* XXX: an user should be able to set this with a control tool, + if not done before 7.0-RELEASE, this needs to be converted + to a device specific sysctl "dev.pcm.X.yyy" via + device_get_sysctl_*() as discussed on multimedia@ in msg-id + <861wujij2q.fsf@xps.des.no> */ SYSCTL_ADD_INT(snd_sysctl_tree(sc->dev), SYSCTL_CHILDREN(snd_sysctl_tree_top(sc->dev)), - OID_AUTO, "spdif_enabled", CTLFLAG_RW, + OID_AUTO, "_spdif_enabled", CTLFLAG_RW, &sc->spdif_enabled, 0, "enable SPDIF output at 44.1 kHz and above"); #endif /* SND_DYNSYSCTL */ diff --git a/sys/dev/sound/pci/es137x.c b/sys/dev/sound/pci/es137x.c index 0f7f387b3933..0851650d461f 100644 --- a/sys/dev/sound/pci/es137x.c +++ b/sys/dev/sound/pci/es137x.c @@ -1360,9 +1360,14 @@ es_init_sysctls(device_t dev) (devid == CT5880_PCI_ID && revid == CT5880REV_CT5880_C) || (devid == CT5880_PCI_ID && revid == CT5880REV_CT5880_D) || (devid == CT5880_PCI_ID && revid == CT5880REV_CT5880_E)) { + /* XXX: an user should be able to set this with a control tool, + if not done before 7.0-RELEASE, this needs to be converted + to a device specific sysctl "dev.pcm.X.yyy" via + device_get_sysctl_*() as discussed on multimedia@ in msg-id + <861wujij2q.fsf@xps.des.no> */ SYSCTL_ADD_PROC(snd_sysctl_tree(dev), SYSCTL_CHILDREN(snd_sysctl_tree_top(dev)), - OID_AUTO, "spdif_enabled", + OID_AUTO, "_spdif_enabled", CTLTYPE_INT | CTLFLAG_RW, dev, sizeof(dev), sysctl_es137x_spdif_enable, "I", "Enable S/PDIF output on primary playback channel"); @@ -1371,9 +1376,14 @@ es_init_sysctls(device_t dev) * Enable fixed rate sysctl if both DAC2 / ADC enabled. */ if (es->ch[ES_DAC2].channel != NULL && es->ch[ES_ADC].channel != NULL) { + /* XXX: an user should be able to set this with a control tool, + if not done before 7.0-RELEASE, this needs to be converted + to a device specific sysctl "dev.pcm.X.yyy" via + device_get_sysctl_*() as discussed on multimedia@ in msg-id + <861wujij2q.fsf@xps.des.no> */ SYSCTL_ADD_PROC(snd_sysctl_tree(dev), SYSCTL_CHILDREN(snd_sysctl_tree_top(dev)), - OID_AUTO, "fixed_rate", + OID_AUTO, "_fixed_rate", CTLTYPE_INT | CTLFLAG_RW, dev, sizeof(dev), sysctl_es137x_fixed_rate, "I", "Enable fixed rate playback/recording"); @@ -1382,9 +1392,14 @@ es_init_sysctls(device_t dev) * Enable single pcm mixer sysctl if both DAC1/2 enabled. */ if (es->ch[ES_DAC1].channel != NULL && es->ch[ES_DAC2].channel != NULL) { + /* XXX: an user should be able to set this with a control tool, + if not done before 7.0-RELEASE, this needs to be converted + to a device specific sysctl "dev.pcm.X.yyy" via + device_get_sysctl_*() as discussed on multimedia@ in msg-id + <861wujij2q.fsf@xps.des.no> */ SYSCTL_ADD_PROC(snd_sysctl_tree(dev), SYSCTL_CHILDREN(snd_sysctl_tree_top(dev)), - OID_AUTO, "single_pcm_mixer", + OID_AUTO, "_single_pcm_mixer", CTLTYPE_INT | CTLFLAG_RW, dev, sizeof(dev), sysctl_es137x_single_pcm_mixer, "I", "Single PCM mixer controller for both DAC1/DAC2"); @@ -1394,6 +1409,9 @@ es_init_sysctls(device_t dev) device_get_unit(dev), "latency_timer", &r) == 0 && !(r < 0 || r > 255)) pci_write_config(dev, PCIR_LATTIMER, r, 1); + /* XXX: this needs to be converted to a device specific sysctl + "dev.pcm.X.yyy" via device_get_sysctl_*() as discussed on + multimedia@ in msg-id <861wujij2q.fsf@xps.des.no> */ SYSCTL_ADD_PROC(snd_sysctl_tree(dev), SYSCTL_CHILDREN(snd_sysctl_tree_top(dev)), OID_AUTO, "latency_timer", diff --git a/sys/dev/sound/pci/ich.c b/sys/dev/sound/pci/ich.c index 429a72214805..0c010ed63d22 100644 --- a/sys/dev/sound/pci/ich.c +++ b/sys/dev/sound/pci/ich.c @@ -561,6 +561,9 @@ static int ich_initsys(struct sc_info* sc) { #ifdef SND_DYNSYSCTL + /* XXX: this should move to a device specific sysctl "dev.pcm.X.yyy" + via device_get_sysctl_*() as discussed on multimedia@ in msg-id + <861wujij2q.fsf@xps.des.no> */ SYSCTL_ADD_INT(snd_sysctl_tree(sc->dev), SYSCTL_CHILDREN(snd_sysctl_tree_top(sc->dev)), OID_AUTO, "ac97rate", CTLFLAG_RW, diff --git a/sys/dev/sound/pci/maestro.c b/sys/dev/sound/pci/maestro.c index 8b97173dd505..102381a7e515 100644 --- a/sys/dev/sound/pci/maestro.c +++ b/sys/dev/sound/pci/maestro.c @@ -189,6 +189,9 @@ static unsigned int powerstate_idle = PCI_POWERSTATE_D1; #endif static unsigned int powerstate_init = PCI_POWERSTATE_D2; +/* XXX: this should move to a device specific sysctl dev.pcm.X.debug.Y via + device_get_sysctl_*() as discussed on multimedia@ in msg-id + <861wujij2q.fsf@xps.des.no> */ SYSCTL_NODE(_debug, OID_AUTO, maestro, CTLFLAG_RD, 0, ""); SYSCTL_UINT(_debug_maestro, OID_AUTO, powerstate_active, CTLFLAG_RW, &powerstate_active, 0, "The Dx power state when active (0-1)"); diff --git a/sys/dev/sound/pci/via8233.c b/sys/dev/sound/pci/via8233.c index a05f9cf716c9..d353b51403bb 100644 --- a/sys/dev/sound/pci/via8233.c +++ b/sys/dev/sound/pci/via8233.c @@ -186,15 +186,19 @@ static void via_init_sysctls(device_t dev) { #ifdef SND_DYNSYSCTL + /* XXX: an user should be able to set this with a control tool, + if not done before 7.0-RELEASE, this needs to be converted to + a device specific sysctl "dev.pcm.X.yyy" via device_get_sysctl_*() + as discussed on multimedia@ in msg-id <861wujij2q.fsf@xps.des.no> */ SYSCTL_ADD_PROC(snd_sysctl_tree(dev), SYSCTL_CHILDREN(snd_sysctl_tree_top(dev)), - OID_AUTO, "spdif_enabled", + OID_AUTO, "_spdif_enabled", CTLTYPE_INT | CTLFLAG_RW, dev, sizeof(dev), sysctl_via8233_spdif_enable, "I", "Enable S/PDIF output on primary playback channel"); SYSCTL_ADD_PROC(snd_sysctl_tree(dev), SYSCTL_CHILDREN(snd_sysctl_tree_top(dev)), - OID_AUTO, "via_dxs_src", + OID_AUTO, "_via_dxs_src", CTLTYPE_INT | CTLFLAG_RW, dev, sizeof(dev), sysctl_via8233_dxs_src, "I", "Enable VIA DXS Sample Rate Converter"); diff --git a/sys/dev/sound/pcm/feeder_rate.c b/sys/dev/sound/pcm/feeder_rate.c index 525f28c553ac..b4496d19d66c 100644 --- a/sys/dev/sound/pcm/feeder_rate.c +++ b/sys/dev/sound/pcm/feeder_rate.c @@ -222,7 +222,9 @@ sysctl_hw_snd_feeder_rate_buffersize(SYSCTL_HANDLER_ARGS) feeder_rate_buffersize = val & ~1; return err; } -SYSCTL_PROC(_hw_snd, OID_AUTO, feeder_rate_buffersize, CTLTYPE_INT | CTLFLAG_RW, +/* XXX: this should be settable by an user via a control tool, the sysadmin + needs a max and min sysctl to limit what an user can do */ +SYSCTL_PROC(_hw_snd, OID_AUTO, _feeder_rate_buffersize, CTLTYPE_INT | CTLFLAG_RW, 0, sizeof(int), sysctl_hw_snd_feeder_rate_buffersize, "I", ""); static void diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index 21381c358884..e2030130fc55 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -40,10 +40,13 @@ int pcm_veto_load = 1; #ifdef USING_DEVFS int snd_unit = 0; -TUNABLE_INT("hw.snd.unit", &snd_unit); +TUNABLE_INT("hw.snd.default_unit", &snd_unit); #endif -int snd_maxautovchans = 0; +int snd_maxautovchans = 4; +/* XXX: a tunable implies that we may need more than one sound channel before + the system can change a sysctl (/etc/sysctl.conf), do we really need + this? */ TUNABLE_INT("hw.snd.maxautovchans", &snd_maxautovchans); SYSCTL_NODE(_hw, OID_AUTO, snd, CTLFLAG_RD, 0, "Sound driver"); @@ -364,7 +367,7 @@ pcm_setmaxautovchans(struct snddev_info *d, int num) #ifdef USING_DEVFS static int -sysctl_hw_snd_unit(SYSCTL_HANDLER_ARGS) +sysctl_hw_snd_default_unit(SYSCTL_HANDLER_ARGS) { struct snddev_info *d; int error, unit; @@ -381,8 +384,9 @@ sysctl_hw_snd_unit(SYSCTL_HANDLER_ARGS) } return (error); } -SYSCTL_PROC(_hw_snd, OID_AUTO, unit, CTLTYPE_INT | CTLFLAG_RW, - 0, sizeof(int), sysctl_hw_snd_unit, "I", ""); +/* XXX: do we need a way to let the user change the default unit? */ +SYSCTL_PROC(_hw_snd, OID_AUTO, default_unit, CTLTYPE_INT | CTLFLAG_RW, + 0, sizeof(int), sysctl_hw_snd_default_unit, "I", ""); #endif static int @@ -867,8 +871,10 @@ pcm_register(device_t dev, void *devinfo, int numplay, int numrec) sysctl_ctx_free(&d->sysctl_tree); goto no; } + /* XXX: an user should be able to set this with a control tool, the + sysadmin then needs min+max sysctls for this */ SYSCTL_ADD_INT(snd_sysctl_tree(dev), SYSCTL_CHILDREN(snd_sysctl_tree_top(dev)), - OID_AUTO, "buffersize", CTLFLAG_RD, &d->bufsz, 0, ""); + OID_AUTO, "_buffersize", CTLFLAG_RD, &d->bufsz, 0, ""); #endif if (numplay > 0) { d->flags |= SD_F_AUTOVCHAN; diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c index bc99714a3c9a..b3fbd257fd10 100644 --- a/sys/dev/sound/pcm/vchan.c +++ b/sys/dev/sound/pcm/vchan.c @@ -607,11 +607,14 @@ vchan_initsys(device_t dev) struct snddev_info *d; d = device_get_softc(dev); + /* XXX: the user should be able to set this with a control tool, the + sysadmin needs a sysctl so set a max value for "vchan" and min+max + values for "vchanrate" to limit what an user can do */ SYSCTL_ADD_PROC(snd_sysctl_tree(dev), SYSCTL_CHILDREN(snd_sysctl_tree_top(dev)), - OID_AUTO, "vchans", CTLTYPE_INT | CTLFLAG_RW, d, sizeof(d), + OID_AUTO, "_vchans", CTLTYPE_INT | CTLFLAG_RW, d, sizeof(d), sysctl_hw_snd_vchans, "I", ""); SYSCTL_ADD_PROC(snd_sysctl_tree(dev), SYSCTL_CHILDREN(snd_sysctl_tree_top(dev)), - OID_AUTO, "vchanrate", CTLTYPE_INT | CTLFLAG_RW, d, sizeof(d), + OID_AUTO, "_vchanrate", CTLTYPE_INT | CTLFLAG_RW, d, sizeof(d), sysctl_hw_snd_vchanrate, "I", ""); #endif