Lines Matching full:pm

37 	struct pcmidi_snd	*pm;  member
94 struct pcmidi_snd *pm = hid_get_drvdata(hdev); in show_channel() local
96 dbg_hid("pcmidi sysfs read channel=%u\n", pm->midi_channel); in show_channel()
98 return sprintf(buf, "%u (min:%u, max:%u)\n", pm->midi_channel, in show_channel()
107 struct pcmidi_snd *pm = hid_get_drvdata(hdev); in store_channel() local
113 pm->midi_channel = channel; in store_channel()
131 struct pcmidi_snd *pm = hid_get_drvdata(hdev); in show_sustain() local
133 dbg_hid("pcmidi sysfs read sustain=%u\n", pm->midi_sustain); in show_sustain()
135 return sprintf(buf, "%u (off:%u, max:%u (ms))\n", pm->midi_sustain, in show_sustain()
144 struct pcmidi_snd *pm = hid_get_drvdata(hdev); in store_sustain() local
150 pm->midi_sustain = sustain; in store_sustain()
151 pm->midi_sustain_mode = (0 == sustain || !pm->midi_mode) ? 0 : 1; in store_sustain()
169 struct pcmidi_snd *pm = hid_get_drvdata(hdev); in show_octave() local
171 dbg_hid("pcmidi sysfs read octave=%d\n", pm->midi_octave); in show_octave()
173 return sprintf(buf, "%d (min:%d, max:%d)\n", pm->midi_octave, in show_octave()
182 struct pcmidi_snd *pm = hid_get_drvdata(hdev); in store_octave() local
189 pm->midi_octave = octave; in store_octave()
203 static void pcmidi_send_note(struct pcmidi_snd *pm, in pcmidi_send_note() argument
213 spin_lock_irqsave(&pm->rawmidi_in_lock, flags); in pcmidi_send_note()
215 if (!pm->in_substream) in pcmidi_send_note()
217 if (!test_bit(pm->in_substream->number, &pm->in_triggered)) in pcmidi_send_note()
220 snd_rawmidi_receive(pm->in_substream, buffer, 3); in pcmidi_send_note()
223 spin_unlock_irqrestore(&pm->rawmidi_in_lock, flags); in pcmidi_send_note()
232 pcmidi_send_note(pms->pm, pms->status, pms->note, pms->velocity); in pcmidi_sustained_note_release()
236 static void init_sustain_timers(struct pcmidi_snd *pm) in init_sustain_timers() argument
242 pms = &pm->sustained_notes[i]; in init_sustain_timers()
244 pms->pm = pm; in init_sustain_timers()
249 static void stop_sustain_timers(struct pcmidi_snd *pm) in stop_sustain_timers() argument
255 pms = &pm->sustained_notes[i]; in stop_sustain_timers()
261 static int pcmidi_get_output_report(struct pcmidi_snd *pm) in pcmidi_get_output_report() argument
263 struct hid_device *hdev = pm->hdev; in pcmidi_get_output_report()
279 pm->pcmidi_report6 = report; in pcmidi_get_output_report()
286 static void pcmidi_submit_output_report(struct pcmidi_snd *pm, int state) in pcmidi_submit_output_report() argument
288 struct hid_device *hdev = pm->hdev; in pcmidi_submit_output_report()
289 struct hid_report *report = pm->pcmidi_report6; in pcmidi_submit_output_report()
296 static int pcmidi_handle_report1(struct pcmidi_snd *pm, u8 *data) in pcmidi_handle_report1() argument
304 dbg_hid("pcmidi mode: %d\n", pm->midi_mode); in pcmidi_handle_report1()
307 if (pm->midi_mode && bit_mask == 0x004000) { in pcmidi_handle_report1()
309 pm->midi_octave--; in pcmidi_handle_report1()
310 if (pm->midi_octave < -2) in pcmidi_handle_report1()
311 pm->midi_octave = -2; in pcmidi_handle_report1()
313 pm->midi_mode, pm->midi_octave); in pcmidi_handle_report1()
317 else if (pm->midi_mode && bit_mask == 0x000004) { in pcmidi_handle_report1()
319 pm->midi_sustain_mode ^= 0x1; in pcmidi_handle_report1()
326 static int pcmidi_handle_report3(struct pcmidi_snd *pm, u8 *data, int size) in pcmidi_handle_report3() argument
338 status = 128 + 16 + pm->midi_channel; /* 1001nnnn */ in pcmidi_handle_report3()
340 (pm->midi_octave * 12); in pcmidi_handle_report3()
344 status = 128 + pm->midi_channel; /* 1000nnnn */ in pcmidi_handle_report3()
346 (pm->midi_octave*12); in pcmidi_handle_report3()
348 if (pm->midi_sustain_mode) { in pcmidi_handle_report3()
350 pms = &pm->sustained_notes[i]; in pcmidi_handle_report3()
359 msecs_to_jiffies(pm->midi_sustain)); in pcmidi_handle_report3()
365 pcmidi_send_note(pm, status, note, velocity); in pcmidi_handle_report3()
371 static int pcmidi_handle_report4(struct pcmidi_snd *pm, u8 *data) in pcmidi_handle_report4() argument
384 input_event(pm->input_ep82, EV_KEY, in pcmidi_handle_report4()
385 pm->last_key[bit_index], 0); in pcmidi_handle_report4()
386 pm->last_key[bit_index] = 0; in pcmidi_handle_report4()
395 pm->fn_state ^= 0x000010; in pcmidi_handle_report4()
396 if (pm->fn_state) in pcmidi_handle_report4()
397 pcmidi_submit_output_report(pm, 0xc5); in pcmidi_handle_report4()
399 pcmidi_submit_output_report(pm, 0xc6); in pcmidi_handle_report4()
402 pcmidi_submit_output_report(pm, 0xc1); in pcmidi_handle_report4()
403 pm->midi_mode ^= 0x01; in pcmidi_handle_report4()
405 dbg_hid("pcmidi mode: %d\n", pm->midi_mode); in pcmidi_handle_report4()
408 dbg_hid("pcmidi mode: %d\n", pm->midi_mode); in pcmidi_handle_report4()
409 if (pm->midi_mode) { in pcmidi_handle_report4()
410 pm->midi_octave++; in pcmidi_handle_report4()
411 if (pm->midi_octave > 2) in pcmidi_handle_report4()
412 pm->midi_octave = 2; in pcmidi_handle_report4()
414 pm->midi_mode, pm->midi_octave); in pcmidi_handle_report4()
475 input_event(pm->input_ep82, EV_KEY, key, 1); in pcmidi_handle_report4()
476 pm->last_key[bit_index] = key; in pcmidi_handle_report4()
484 struct pcmidi_snd *pm, unsigned report_id, u8 *data, int size) in pcmidi_handle_report() argument
490 ret = pcmidi_handle_report1(pm, data); in pcmidi_handle_report()
493 ret = pcmidi_handle_report3(pm, data, size); in pcmidi_handle_report()
496 ret = pcmidi_handle_report4(pm, data); in pcmidi_handle_report()
503 struct pcmidi_snd *pm, struct input_dev *input) in pcmidi_setup_extra_keys() argument
528 if (pm->ifnum != 1) /* only set up ONCE for interace 1 */ in pcmidi_setup_extra_keys()
531 pm->input_ep82 = input; in pcmidi_setup_extra_keys()
534 pm->last_key[i] = 0; in pcmidi_setup_extra_keys()
537 set_bit(*pkeys, pm->input_ep82->keybit); in pcmidi_setup_extra_keys()
542 static int pcmidi_set_operational(struct pcmidi_snd *pm) in pcmidi_set_operational() argument
546 if (pm->ifnum != 1) in pcmidi_set_operational()
549 rc = pcmidi_get_output_report(pm); in pcmidi_set_operational()
552 pcmidi_submit_output_report(pm, 0xc1); in pcmidi_set_operational()
563 struct pcmidi_snd *pm = substream->rmidi->private_data; in pcmidi_in_open() local
566 pm->in_substream = substream; in pcmidi_in_open()
578 struct pcmidi_snd *pm = substream->rmidi->private_data; in pcmidi_in_trigger() local
582 pm->in_triggered = up; in pcmidi_in_trigger()
591 static int pcmidi_snd_initialise(struct pcmidi_snd *pm) in pcmidi_snd_initialise() argument
602 if (pm->ifnum != 1) in pcmidi_snd_initialise()
615 err = snd_card_new(&pm->hdev->dev, index[dev], id[dev], in pcmidi_snd_initialise()
622 pm->card = card; in pcmidi_snd_initialise()
625 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, pm, &ops); in pcmidi_snd_initialise()
644 pm->rwmidi = rwmidi; in pcmidi_snd_initialise()
647 rwmidi->private_data = pm; in pcmidi_snd_initialise()
653 err = device_create_file(&pm->hdev->dev, in pcmidi_snd_initialise()
661 err = device_create_file(&pm->hdev->dev, in pcmidi_snd_initialise()
669 err = device_create_file(&pm->hdev->dev, in pcmidi_snd_initialise()
677 spin_lock_init(&pm->rawmidi_in_lock); in pcmidi_snd_initialise()
679 init_sustain_timers(pm); in pcmidi_snd_initialise()
680 err = pcmidi_set_operational(pm); in pcmidi_snd_initialise()
698 stop_sustain_timers(pm); in pcmidi_snd_initialise()
699 device_remove_file(&pm->hdev->dev, sysfs_device_attr_octave); in pcmidi_snd_initialise()
701 device_remove_file(&pm->hdev->dev, sysfs_device_attr_sustain); in pcmidi_snd_initialise()
703 device_remove_file(&pm->hdev->dev, sysfs_device_attr_channel); in pcmidi_snd_initialise()
705 if (pm->card) { in pcmidi_snd_initialise()
706 snd_card_free(pm->card); in pcmidi_snd_initialise()
707 pm->card = NULL; in pcmidi_snd_initialise()
712 static int pcmidi_snd_terminate(struct pcmidi_snd *pm) in pcmidi_snd_terminate() argument
714 if (pm->card) { in pcmidi_snd_terminate()
715 stop_sustain_timers(pm); in pcmidi_snd_terminate()
717 device_remove_file(&pm->hdev->dev, sysfs_device_attr_channel); in pcmidi_snd_terminate()
718 device_remove_file(&pm->hdev->dev, sysfs_device_attr_sustain); in pcmidi_snd_terminate()
719 device_remove_file(&pm->hdev->dev, sysfs_device_attr_octave); in pcmidi_snd_terminate()
721 snd_card_disconnect(pm->card); in pcmidi_snd_terminate()
722 snd_card_free_when_closed(pm->card); in pcmidi_snd_terminate()
749 struct pcmidi_snd *pm = hid_get_drvdata(hdev); in pk_input_mapping() local
752 1 == pm->ifnum) { in pk_input_mapping()
753 pcmidi_setup_extra_keys(pm, hi->input); in pk_input_mapping()
764 struct pcmidi_snd *pm = hid_get_drvdata(hdev); in pk_raw_event() local
767 if (1 == pm->ifnum) { in pk_raw_event()
773 ret = pcmidi_handle_report(pm, in pk_raw_event()
788 struct pcmidi_snd *pm; in pk_probe() local
796 pm = kzalloc(sizeof(*pm), GFP_KERNEL); in pk_probe()
797 if (pm == NULL) { in pk_probe()
802 pm->hdev = hdev; in pk_probe()
803 pm->ifnum = ifnum; in pk_probe()
805 hid_set_drvdata(hdev, pm); in pk_probe()
823 ret = pcmidi_snd_initialise(pm); in pk_probe()
831 kfree(pm); in pk_probe()
838 struct pcmidi_snd *pm = hid_get_drvdata(hdev); in pk_remove() local
840 pcmidi_snd_terminate(pm); in pk_remove()
843 kfree(pm); in pk_remove()