Giter VIP home page Giter VIP logo

init-headphone's Introduction

init-headphone

Manage the headphone amplifier found in some Clevo laptops. Can initialize the device if headphones are not working after suspend.

There are packages for Arch Linux, Fedora and Ubuntu

Installation

To install just run:

./autogen.sh
./configure
make
make install

If systemd is available, a unit file that starts the program automatically gets installed. To enable it run:

systemctl enable init-headphone

If you are not using systemd, take a look at the etc/ folder. It includes example configuration for pm-utils and upstart to start the program automatically.

On older Linux versions you might have to add the kernel parameter acpi_enforce_resources=lax to make the i2c driver work.

Usage

init-headphone --help
usage: init-headphone [-h] [--version] [-v] [command]

Manage the headphone amplifier found in some Clevo laptops

positional arguments:
  command        see the list of available commands below, init is the default
                 if the argument is omitted

optional arguments:
  -h, --help     show this help message and exit
  --version      show program's version number and exit
  -v, --verbose  increase output verbosity

available commands:
  init           initialize amplifier (with effect1)
  effect0        no change
  effect1        bass boost
  effect2
  effect3
  effect4        boost everything
  effect5
  effect6
  mute           turn output off
  unmute         turn output on
  recovery

Troubleshoot

  • Run init-headphone with the --verbose argument.
  • Use dmesg | grep i801 to check for problems with the SMBus driver.
  • List all i2c busses with i2cdetect -l to find the full name of the bus SMBus I801 adapter.... Use that name as a argument for i2cdetect like i2cdetect "SMBus I801 adapter at f040". This should show the headphone amplifier at address 0x73.

Information about the Windows driver

The Windows driver consists of a kernel space component SvThANSP.sys and a user space component hp.dll. The kernel driver is simple and only supports a few commands that allow access to I/O ports. hp.dll uses DeviceIoControl to communicates via the device file \\.\SvANSPDo with the driver. It talks directly to the SMBus controller.

hp.dll exports the functions InitHeadphone(), Set_Mute(bool) and Set_effect(int) to control the headphone amplifier which is connected to the SMBus.

If you are interested in analyzing or running the Windows driver on Linux (with Wine) take a look at: https://github.com/Unrud/init-headphone-tools

Supported dwIoControlCodes for DeviceIoControl

0x9C402494: Enumerate PCI device

lpInBuffer amd lpOutBuffer look something like:

struct {
    int bus,
    int device,
    int func,
    int pcireg,
    int result,
    int unused
}

The driver reads a word from the register pcireg of the PCI device specified by bus, device and func. The result is returned in result. If the register doesn't exist, the returned result is 0xffff. It's used to find the SMBus controller by hp.dll.

0x9C4024D0: Read byte

lpInBuffer amd lpOutBuffer look something like:

struct {
    int address,
    int data_read,
    int data_write
}

The driver reads one byte from address. The result is returned in data_read.

0x9C4024C4: Write byte

lpInBuffer amd lpOutBuffer are the same as above.

The driver writes one byte data_write to address.

SMBus controller

A detailed description of the controller is available in the chipset datasheet.

The important registers are:

  • Transmit Slave Address Register: Bit 0 indicates direction, the other 7 Bits are the device address (Offset: 0x4)
  • Host Command Register: Command (Offset: 0x3)
  • Host Data 0 Register: Data (Offset: 0x5)

Supported models

This list is subject to change. If the headphone jack is not working after suspend, the model is probably supported.

x is used as wildcard

  • N151SD/N155SD/N170SD/N150SC/N151SC/N155SC
  • P15xSM-A/P17xSM-A Series
  • P370SM-A/P375SM-A/P377SM-A Series
  • P641HK1
  • P65xSE
  • W130SV
  • W230SD
  • W230SS
  • W25CSV/W25CSW
  • W330AU
  • W330SU2
  • W355SDQ
  • W35xSSQ/W37xSS Series
  • W510TU
  • W510TU-L
  • W51xLU/-C
  • W5xxSU2
  • W650SB/W655SB/W670SBQ/W670SBQ1 Series
  • W65xSF Series
  • W65xSJ Series
  • W67xSFQ Series
  • W67xSJQ Series
  • W840AU
  • W940AU/W941AU-T/W945AU/W950AU/W955AU Series
  • W940TU/W945TU Series
  • W942SV/W942SV1
  • W942SW/W942SW1
  • W945SUW
  • W94xKU/W95xKU
  • W94xLU/-C/W95xLU/-C/W970LU
  • W94xSU1
  • W94xSU2/W95xSU2/W945SUY
  • W94xTU-L
  • W95xKL Series
  • W95xTU Series
  • W970KLQ
  • W970SUY
  • W970TUQ
  • WA50SBQ
  • WA50SFQ Series
  • WA50SJQ Series

init-headphone's People

Contributors

dantali0n avatar unrud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

init-headphone's Issues

P650RS Support possible?

Hi,
not an issue, but maybe its possible to get another supported notebook.
I´ve a brand new P650RS with Debian 8 (Stretch). Do you think its possible to get support of it?
It would be really great if it is.
I´ll help where i can

Greets

Add support for the Clevo P751DM2-G

Hello there,

I tried this package on the aforementioned system in an attempt to get the 3.5mm amplified audio jack to work but to no avail.

The information on attempting to get this setup to work with the ALSA stack can be found here: https://gist.github.com/Brainiarc7/e21f25333ad0704d729337a44ec60e4b

Is it possible to add support for the Realtek ALC898, as found on current generation Clevo systems?

Let me know if you need any further debugging information that may aid in such an effort.

Warm regards,

Brainiarc7.

Supported models are confusing

When I first find this package, I am confused by the "supported models" because it doesn't contain the model of my laptop p150sm-a. I guess this probably works on all the clevo laptops (if that laptop needs to reinit its heaadphone) so maybe the supported models can be removed. (I have already seen that model check has been removed from the source code)

"Can't find I2C bus" on Ubuntu 16.04

INFO:root:Version: 0.11
WARNING:root:Kernel parameter is missing: acpi_enforce_resources=lax
INFO:root:Trying to add module to the kernel: i2c_dev
INFO:root:Trying to add module to the kernel: i2c_i801
DEBUG:root:Available i2c busses: ['i915 gmbus ssc', 'i915 gmbus vga', 'i915 gmbus panel', 'i915 gmbus dpc', 'i915 gmbus dpb', 'i915 gmbus dpd', 'DPDDC-A', 'DPDDC-B']
DEBUG:root:Supported i2c bus names: ['SMBus I801 adapter']
ERROR:root:Can't find i2c bus
ERROR:root:Operation failed
DEBUG:root:Exception occurred:
Traceback (most recent call last):
File "src/init-headphone", line 322, in
main()
File "src/init-headphone", line 308, in main
init()
File "src/init-headphone", line 240, in init
set_effect(DEFAULT_EFFECT)
File "src/init-headphone", line 256, in set_effect
DATA_ENABLE_OUTPUT)
File "src/init-headphone", line 232, in write_data_to_device
with do_checks_and_get_i2c_bus() as i2c_bus:
File "src/init-headphone", line 219, in do_checks_and_get_i2c_bus
raise RuntimeError("Can't find i2c bus")
RuntimeError: Can't find i2c bus

Any suggestions?

Add documentation for Systemd-suspend hook

I suggest to add at least to the README instructions to schedule automatic headphones reinitialization after resuming from suspension state. I can provide the README and the trivial configuration file needed to automatically execute init-headphone on resume. Just tell me if it would be helpful and I'll contribute with a PR. From a packaging perspective, a new file has to be deployed, and I'm actually found only on Ubuntu, but basically systemd-supend uses one of two possible paths so it wouldn't be too difficult to address all distros in principle.

PS: my machine is a Clevo W230SD.

Clevo P775DM3(G) Support Request

I have tried init-headphone on my p775dm3 with unsuccessful attempt.
Audio Codec: ALC898
The information given in the console is listed below:
INFO:Version: 0.12
INFO:Trying to add module to the kernel: i2c_dev
INFO:Trying to add module to the kernel: i2c_i801
DEBUG:Available i2c busses: ['0000:01:00.0', 'nvkm-0000:01:00.0-aux-0004', 'nvkm-0000:01:00.0-aux-0009', 'nvkm-0000:01:00.0-bus-0002', 'nvkm-0000:01:00.0-aux-0008', 'nvkm-0000:01:00.0-bus-0007', 'nvkm-0000:01:00.0-bus-0006', '0000:01:00.0', 'nvkm-0000:01:00.0-bus-0005', '0000:01:00.0', 'nvkm-0000:01:00.0-bus-0004', 'nvkm-0000:01:00.0-bus-0009', 'nvkm-0000:01:00.0-bus-0001', 'nvkm-0000:01:00.0-aux-0007', 'nvkm-0000:01:00.0-bus-0008', 'nvkm-0000:01:00.0-aux-0006', 'SMBus I801 adapter at f000', 'nvkm-0000:01:00.0-aux-0005']
DEBUG:Supported i2c bus names: ['SMBus I801 adapter']
DEBUG:Selected i2c bus: SMBus I801 adapter at f000
INFO:Opening I2C bus: /dev/i2c-17
INFO:Setting I2C slave address: 115
INFO:Writing byte data on I2C bus: (device_cmd: 0xa, value: 0x41)
ERROR:Can't transfer data on I2C bus
INFO:Closing I2C bus
ERROR:Operation failed
DEBUG:Exception occurred:
Traceback (most recent call last):
File "/usr/local/sbin/init-headphone", line 351, in
main()
File "/usr/local/sbin/init-headphone", line 309, in main
init()
File "/usr/local/sbin/init-headphone", line 241, in init
set_effect(DEFAULT_EFFECT)
File "/usr/local/sbin/init-headphone", line 257, in set_effect
DATA_ENABLE_OUTPUT)
File "/usr/local/sbin/init-headphone", line 235, in write_data_to_device
write_prolog(i2c_bus)
File "/usr/local/sbin/init-headphone", line 226, in write_prolog
i2c_bus.write_byte_data(0x0a, 0x41)
File "/usr/local/sbin/init-headphone", line 143, in write_byte_data
self.__access(I2C_SMBUS_WRITE, device_cmd, I2C_SMBUS_BYTE_DATA, data)
File "/usr/local/sbin/init-headphone", line 135, in __access
raise OSError(err, os.strerror(err))
OSError: [Errno -1] Unknown error -1

XMG P305 not working

Hello,
I have a XMG P305 this is a German rebrand form the w230sd and i have the same issue with my Audioport. Can you add this Notebook to the Script?
dmidecode -s baseboard-product-name output:
# SMBIOS implementations newer than version 2.7 are not
# fully supported by this version of dmidecode.
XMG P305
Thanks THS

Outputs "Unsupported system ()" on One Notebook K33-4E

I have this notebook which uses the Clevo W230SS barebone.

The script returns "Unsupported system ()". dmidecode -s system-product-name returns an empty string.

When adding "" to SUPPORTED_SYSTEM_PRODUCT_NAMES, it correctly reenables the headphone jack.

Any other ways to identify the system without dmidecode?

Gentoo repo

Hello,

Thanks for replying in https://bugzilla.kernel.org/show_bug.cgi?id=75151
Already utilized your fresh script for my system and it works perfectly!

Wanted to propose to make a gentoo repo for this.
Its pretty easy to make, simplest example you can find here: https://github.com/gentoo-mirror/yoreek
After that on my gentoo system I just add:

% cat /etc/portage/repos.conf/yoreek.conf 
[yoreek]
location = /usr/local/portage/yoreek
sync-type = git
sync-uri = https://github.com/gentoo-mirror/yoreek.git
auto-sync = true

More complex example: https://github.com/nE0sIghT/vortex-overlay
Really complex but full example: https://github.com/dantrell/gentoo-overlay-dantrell-gnome

Let me know your thoughts.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.