/* * Interface for OSS sequencer emulation * * Copyright (C) 2000 Uros Bizjak * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include "opl3_voice.h" static int snd_opl3_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure); static int snd_opl3_close_seq_oss(struct snd_seq_oss_arg *arg); static int snd_opl3_ioctl_seq_oss(struct snd_seq_oss_arg *arg, unsigned int cmd, unsigned long ioarg); static int snd_opl3_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format, const char __user *buf, int offs, int count); static int snd_opl3_reset_seq_oss(struct snd_seq_oss_arg *arg); /* */ static inline mm_segment_t snd_enter_user(void) { mm_segment_t fs = get_fs(); set_fs(get_ds()); return fs; } static inline void snd_leave_user(mm_segment_t fs) { set_fs(fs); } /* operators */ extern struct snd_midi_op opl3_ops; static struct snd_seq_oss_callback oss_callback = { .owner = THIS_MODULE, .open = snd_opl3_open_seq_oss, .close = snd_opl3_close_seq_oss, .ioctl = snd_opl3_ioctl_seq_oss, .load_patch = snd_opl3_load_patch_seq_oss, .reset = snd_opl3_reset_seq_oss, }; static int snd_opl3_oss_event_input(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop) { struct snd_opl3 *opl3 = private_data; if (ev->type != SNDRV_SEQ_EVENT_OSS) snd_midi_process_event(&opl3_ops, ev, opl3->oss_chset); return 0; } /* ------------------------------ */ static void snd_opl3_oss_free_port(void *private_data) { struct snd_opl3 *opl3 = private_data; snd_midi_channel_free_set(opl3->oss_chset); } static int snd_opl3_oss_create_port(struct snd_opl3 * opl3) { struct snd_seq_port_callback callbacks; char name[32]; int voices, opl_ver; voices = (opl3->hardware < OPL3_HW_OPL3) ? MAX_OPL2_VOICES : MAX_OPL3_VOICES; opl3->oss_chset = snd_midi_channel_alloc_set(voices); if (opl3->oss_chset == NULL) return -ENOMEM; opl3->oss_chset->private_data = opl3; memset(&callbacks, 0, sizeof(callbacks)); callbacks.owner = THIS_MODULE; callbacks.event_input = snd_opl3_oss_event_input; callbacks.private_free = snd_opl3_oss_free_port; callbacks.private_data = opl3; opl_ver = (opl3->hardware & OPL3_HW_MASK) >> 8; sprintf(name, "OPL%i OSS Port", opl_ver); opl3->oss_chset->client = opl3->seq_client; opl3->oss_chset->port = snd_seq_event_port_attach(opl3->seq_client, &callbacks, SNDRV_SEQ_PORT_CAP_WRITE, SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC | SNDRV_SEQ_PORT_TYPE_MIDI_GM | SNDRV_SEQ_PORT_TYPE_HARDWARE | SNDRV_SEQ_PORT_TYPE_SYNTHESIZER, voices, voices, name); if (opl3->oss_chset->port < 0) { int port; port = opl3->oss_chset->port; snd_midi_channel_free_set(opl3->oss_chset); return port; } return 0; } /* ------------------------------ */ /* register OSS synth */ void snd_opl3_init_seq_oss(struct snd_opl3 *opl3, char *name) { struct snd_seq_oss_reg *arg; struct snd_seq_device *dev; if (snd_seq_device_new(opl3->card, 0, SNDRV_SEQ_DEV_ID_OSS, sizeof(struct snd_seq_oss_reg), &dev) < 0) return; opl3->oss_seq_dev = dev; strlcpy(dev->name, name, sizeof(dev->name)); arg = SNDRV_SEQ_DEVICE_ARGPTR(dev); arg->type = SYNTH_TYPE_FM; if (opl3->hardware < OPL3_HW_OPL3) { arg->subtype = FM_TYPE_ADLIB; arg->nvoices = MAX_OPL2_VOICES; } else { arg->subtype = FM_TYPE_OPL3; arg->nvoices = MAX_OPL3_VOICES; } arg->oper = oss_callback; arg->private_data = opl3; if (snd_opl3_oss_create_port(opl3)) { /* register to OSS synth table */ snd_device_register(opl3->card, dev); } } /* unregister */ void snd_opl3_free_seq_oss(struct snd_opl3 *opl3) { if (opl3->oss_seq_dev) { /* The instance should have been released in prior */ opl3->oss_seq_dev = NULL; } } /* ------------------------------ */ /* open OSS sequencer */ static int snd_opl3_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure) { struct snd_opl3 *opl3 = closure; int err; if (snd_BUG_ON(!arg)) return -ENXIO; if ((err = snd_opl3_synth_setup(opl3)) < 0) return err; /* fill the argument data */ arg->private_data = opl3; arg->addr.client = opl3->oss_chset->client; arg->addr.port = opl3->oss_chset->port; if ((err = snd_opl3_synth_use_inc(opl3)) < 0) return err; opl3->synth_mode = SNDRV_OPL3_MODE_SYNTH; return 0; } /* close OSS sequencer */ static int snd_opl3_close_seq_oss(struct snd_seq_oss_arg *arg) { struct snd_opl3 *opl3; if (snd_BUG_ON(!arg)) return -ENXIO; opl3 = arg->private_data; snd_opl3_synth_cleanup(opl3); snd_opl3_synth_use_dec(opl3); return 0; } /* load patch */ /* from sound_config.h */ #define SBFM_MAXINSTR 256 static int snd_opl3_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format, const char __user *buf, int offs, int count) { struct snd_opl3 *opl3; struct sbi_instrument sbi; char name[32]; int err, type; if (snd_BUG_ON(!arg)) return -ENXIO; opl3 = arg->private_data; if (format == FM_PATCH) type = FM_PATCH_OPL2; else if (format == OPL3_PATCH) type = FM_PATCH_OPL3; else return -EINVAL; if (count < (int)sizeof(sbi)) { snd_printk(KERN_ERR "FM Error: Patch record too short\n"); return -EINVAL; } if (copy_from_user(&sbi, buf, sizeof(sbi))) return -EFAULT; if (sbi.channel < 0 || sbi.channel >= SBFM_MAXINSTR) { snd_printk(KERN_ERR "FM Error: Invalid instrument number %d\n", sbi.channel); return -EINVAL; } memset(name, 0, sizeof(name)); sprintf(name, "Chan%d", sbi.channel); err = snd_opl3_load_patch(opl3, sbi.channel, 127, type, name, NULL, sbi.operators); if (err < 0) return err; return sizeof(sbi); } /* ioctl */ static int snd_opl3_ioctl_seq_oss(struct snd_seq_oss_arg *arg, unsigned int cmd, unsigned long ioarg) { struct snd_opl3 *opl3; if (snd_BUG_ON(!arg)) return -ENXIO; opl3 = arg->private_data; switch (cmd) { case SNDCTL_FM_LOAD_INSTR: snd_printk(KERN_ERR "OPL3: " "Obsolete ioctl(SNDCTL_FM_LOAD_INSTR) used. " "Fix the program.\n"); return -EINVAL; case SNDCTL_SYNTH_MEMAVL: return 0x7fffffff; case SNDCTL_FM_4OP_ENABLE: // handled automatically by OPL instrument type return 0; default: return -EINVAL; } return 0; } /* reset device */ static int snd_opl3_reset_seq_oss(struct snd_seq_oss_arg *arg) { struct snd_opl3 *opl3; if (snd_BUG_ON(!arg)) return -ENXIO; opl3 = arg->private_data; return 0; } ---------------------------------------- Disabling lock debugging due to kernel taint INFO: Allocated in drm_atomic_helper_setup_commit+0x285/0x2f0 [drm_kms_helper] age=0 cpu=3 pid=1529 ___slab_alloc+0x308/0x3b0 __slab_alloc+0xd/0x20 kmem_cache_alloc_trace+0x92/0x1c0 drm_atomic_helper_setup_commit+0x285/0x2f0 [drm_kms_helper] intel_atomic_commit+0x35/0x4f0 [i915] drm_atomic_commit+0x46/0x50 [drm] drm_mode_atomic_ioctl+0x7d4/0xab0 [drm] drm_ioctl+0x2b3/0x490 [drm] do_vfs_ioctl+0x69c/0x700 SyS_ioctl+0x4e/0x80 entry_SYSCALL_64_fastpath+0x13/0x94 INFO: Freed in drm_event_cancel_free+0xa3/0xb0 [drm] age=0 cpu=3 pid=1529 __slab_free+0x48/0x2e0 kfree+0x159/0x1a0 drm_event_cancel_free+0xa3/0xb0 [drm] drm_mode_atomic_ioctl+0x86d/0xab0 [drm] drm_ioctl+0x2b3/0x490 [drm] do_vfs_ioctl+0x69c/0x700 SyS_ioctl+0x4e/0x80 entry_SYSCALL_64_fastpath+0x13/0x94 INFO: Slab 0xffffde1f0997b080 objects=17 used=2 fp=0xffff92fb65ec2578 flags=0x200000000008101 INFO: Object 0xffff92fb65ec2578 @offset=1400 fp=0xffff92fb65ec2ae8 Redzone ffff92fb65ec2570: bb bb bb bb bb bb bb bb ........ Object ffff92fb65ec2578: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec2588: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec2598: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec25a8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec25b8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec25c8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec25d8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec25e8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5 kkkkkkkkkkkkkkk. Redzone ffff92fb65ec25f8: bb bb bb bb bb bb bb bb ........ Padding ffff92fb65ec2738: 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ CPU: 3 PID: 180 Comm: kworker/3:2 Tainted: G BU 4.10.0-rc6-patser+ #5039 Hardware name: /NUC5PPYB, BIOS PYBSWCEL.86A.0031.2015.0601.1712 06/01/2015 Workqueue: events intel_atomic_helper_free_state [i915] Call Trace: dump_stack+0x4d/0x6d print_trailer+0x20c/0x220 free_debug_processing+0x1c6/0x330 ? drm_atomic_state_default_clear+0xf7/0x1c0 [drm] __slab_free+0x48/0x2e0 ? drm_atomic_state_default_clear+0xf7/0x1c0 [drm] kfree+0x159/0x1a0 drm_atomic_state_default_clear+0xf7/0x1c0 [drm] ? drm_atomic_state_clear+0x30/0x30 [drm] intel_atomic_state_clear+0xd/0x20 [i915] drm_atomic_state_clear+0x1a/0x30 [drm] __drm_atomic_state_free+0x13/0x60 [drm] intel_atomic_helper_free_state+0x5d/0x70 [i915] process_one_work+0x260/0x4a0 worker_thread+0x2d1/0x4f0 kthread+0x127/0x130 ? process_one_work+0x4a0/0x4a0 ? kthread_stop+0x120/0x120 ret_from_fork+0x29/0x40 FIX kmalloc-128: Object at 0xffff92fb65ec2578 not freed Fixes: 3b24f7d67581 ("drm/atomic: Add struct drm_crtc_commit to track async updates") Fixes: 9626014258a5 ("drm/fence: add in-fences support") Cc: <stable@vger.kernel.org> # v4.8+ Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/1485854725-27640-1-git-send-email-maarten.lankhorst@linux.intel.com
Diffstat (limited to 'sound/soc/codecs/cs42l42.h')