Revision 5cd8846c3b7c104135ee602ab1887f4c1de445ef authored by Linus Torvalds on 16 March 2013, 00:35:49 UTC, committed by Linus Torvalds on 16 March 2013, 00:35:49 UTC
Pull sound fixes from Takashi Iwai:
 "A collection of small fixes, as expected for the middle rc:
   - A couple of fixes for potential NULL dereferences and out-of-range
     array accesses revealed by static code parsers
   - A fix for the wrong error handling detected by trinity
   - A regression fix for missing audio on some MacBooks
   - CA0132 DSP loader fixes
   - Fix for EAPD control of IDT codecs on machines w/o speaker
   - Fix a regression in the HD-audio widget list parser code
   - Workaround for the NuForce UDH-100 USB audio"

* tag 'sound-3.9' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
  ALSA: hda - Fix missing EAPD/GPIO setup for Cirrus codecs
  sound: sequencer: cap array index in seq_chn_common_event()
  ALSA: hda/ca0132 - Remove extra setting of dsp_state.
  ALSA: hda/ca0132 - Check download state of DSP.
  ALSA: hda/ca0132 - Check if dspload_image succeeded.
  ALSA: hda - Disable IDT eapd_switch if there are no internal speakers
  ALSA: hda - Fix snd_hda_get_num_raw_conns() to return a correct value
  ALSA: usb-audio: add a workaround for the NuForce UDH-100
  ALSA: asihpi - fix potential NULL pointer dereference
  ALSA: seq: Fix missing error handling in snd_seq_timer_open()
2 parent s c7f17de + 6d3073e
Raw File
via-pmu-event.c
/*
 * via-pmu event device for reporting some events that come through the PMU
 *
 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
 *
 * 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, GOOD TITLE or
 * NON INFRINGEMENT.  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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 *
 */

#include <linux/input.h>
#include <linux/adb.h>
#include <linux/pmu.h>
#include "via-pmu-event.h"

static struct input_dev *pmu_input_dev;

static int __init via_pmu_event_init(void)
{
	int err;

	/* do other models report button/lid status? */
	if (pmu_get_model() != PMU_KEYLARGO_BASED)
		return -ENODEV;

	pmu_input_dev = input_allocate_device();
	if (!pmu_input_dev)
		return -ENOMEM;

	pmu_input_dev->name = "PMU";
	pmu_input_dev->id.bustype = BUS_HOST;
	pmu_input_dev->id.vendor = 0x0001;
	pmu_input_dev->id.product = 0x0001;
	pmu_input_dev->id.version = 0x0100;

	set_bit(EV_KEY, pmu_input_dev->evbit);
	set_bit(EV_SW, pmu_input_dev->evbit);
	set_bit(KEY_POWER, pmu_input_dev->keybit);
	set_bit(SW_LID, pmu_input_dev->swbit);

	err = input_register_device(pmu_input_dev);
	if (err)
		input_free_device(pmu_input_dev);
	return err;
}

void via_pmu_event(int key, int down)
{

	if (unlikely(!pmu_input_dev))
		return;

	switch (key) {
	case PMU_EVT_POWER:
		input_report_key(pmu_input_dev, KEY_POWER, down);
		break;
	case PMU_EVT_LID:
		input_report_switch(pmu_input_dev, SW_LID, down);
		break;
	default:
		/* no such key handled */
		return;
	}

	input_sync(pmu_input_dev);
}

late_initcall(via_pmu_event_init);
back to top