usb_webcam: on/off dependent on capture client

This commit removes the report service from the usb_webcam pkg, which
was used to enable or disable the webcam driver. The on/off state is
instead controlled by the presence of a capture client. That is, once a
capture client appears, the webcam driver is started. Vice versa, once
no capture client exists, the webcam driver is removed automatically.

Internally, the detection of presence of a capture client is based on
nitpicker's 'displays' report, which is consumed as input of the
rom_filter, which in turn generates the configuration of a dynamic sub
init.

Fixes #4287
This commit is contained in:
Norman Feske 2021-10-07 10:33:11 +02:00
parent bc5a7eb495
commit eb80d6ce66
2 changed files with 15 additions and 13 deletions

View File

@ -1,5 +1,5 @@
<runtime binary="init" caps="800" ram="64M" config="usb_webcam.config">
<provides> <capture /> <report /> </provides>
<provides> <capture /> </provides>
<requires> <timer /> <usb /> <rm /> </requires>
<content>
<rom label="ld.lib.so"/>

View File

@ -12,7 +12,6 @@
<default caps="100"/>
<service name="Report"> <default-policy> <child name="report_rom" label="capture"/> </default-policy> </service>
<service name="Capture"> <default-policy> <child name="nitpicker_camera"/> </default-policy> </service>
<start name="nitpicker_camera" caps="150">
@ -22,11 +21,13 @@
<service name="Gui"/> <service name="Capture"/>
</provides>
<config request_framebuffer="no">
<report displays="yes"/>
<capture/>
<domain name="" layer="1" content="client" label="no" />
<default-policy domain=""/>
</config>
<route>
<service name="Report"> <child name="report_rom"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
@ -36,25 +37,28 @@
<resource name="RAM" quantum="2M"/>
<provides> <service name="Report"/> <service name="ROM"/> </provides>
<config verbose="no">
<policy label="capture" report="capture"/>
<policy label="webcam_config -> displays" report="nitpicker_camera -> displays"/>
</config>
<route>
<any-service> <parent /> </any-service>
</route>
</start>
<start name="webcam-config">
<start name="webcam_config">
<binary name="rom_filter"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="ROM"/> </provides>
<config verbose="no">
<input name="webcam_enabled" rom="capture" node="capture">
<attribute name="enabled"/>
<input name="capture_width" rom="displays" node="displays" default="">
<node type="display">
<attribute name="width"/>
</node>
</input>
<output node="config">
<if> <has_value input="webcam_enabled" value="true"/>
<then>
<if> <has_value input="capture_width" value=""/>
<then> </then>
<else>
<inline>
<parent-provides>
<service name="ROM"/>
@ -82,13 +86,11 @@
</route>
</start>
</inline>
</then></if>
</else></if>
</output>
</config>
<route>
<service name="ROM" label="capture">
<child name="report_rom" label="capture"/>
</service>
<service name="ROM" label="displays"> <child name="report_rom"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
@ -98,7 +100,7 @@
<resource name="RAM" quantum="50MB"/>
<route>
<service name="ROM" label="config">
<child name="webcam-config" label="config"/>
<child name="webcam_config" label="config"/>
</service>
<service name="Gui"> <child name="nitpicker_camera"/> </service>
<any-service> <parent/> </any-service>