Bug 197773 - [snd_hda][patch] Sending a devctl notifications when headphones are connected/disconnected
Summary: [snd_hda][patch] Sending a devctl notifications when headphones are connected...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 10.1-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-multimedia (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2015-02-17 23:41 UTC by ebfe
Modified: 2021-02-27 20:39 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ebfe 2015-02-17 23:41:51 UTC
It would be nice to have devctl/devd notifications when headphones are connected/disconnected.

E.g.,
cat /var/run/devd.pipe
!system=SND_HDA subsystem=headphones type=connection state=disconnected
!system=SND_HDA subsystem=headphones type=connection state=connected

So, with some devd.conf-magic one could easily preserve and restore mixer (or hw.snd.default_unit) settings.

Maybe, something like this:
Index: /usr/src/sys/dev/sound/pci/hda/hdaa.c
===================================================================
*** /usr/src/sys/dev/sound/pci/hda/hdaa.c	(revision 278924)
--- /usr/src/sys/dev/sound/pci/hda/hdaa.c	(working copy)
***************
*** 381,394 ****
--- 381,397 ----
  	struct hdaa_devinfo *devinfo = w->devinfo;
  	struct hdaa_audio_as *as = &devinfo->as[w->bindas];
  	struct hdaa_widget *w1;
  	struct hdaa_audio_ctl *ctl;
  	uint32_t val;
  	int j, connected = w->wclass.pin.connected;
  
+ 	devctl_notify("SND_HDA", "headphones", "connection", 
+ 		connected ? "state=connected" : "state=disconnected");
+ 
  	HDA_BOOTVERBOSE(
  		device_printf((as->pdevinfo && as->pdevinfo->dev) ?
  		    as->pdevinfo->dev : devinfo->dev,
  		    "Redirect output to: %s\n",
  		    connected ? "headphones": "main");
  	);
  	/* (Un)Mute headphone pin. */