Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions caas/BoardConfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ BOARD_SEPOLICY_DIRS += $(INTEL_PATH_SEPOLICY)/bxt_usb
# i915_async
BOARD_SEPOLICY_DIRS += $(INTEL_PATH_SEPOLICY)/i915_async

#for clipboard agent
PRODUCT_PRIVATE_SEPOLICY_DIRS += $(INTEL_PATH_SEPOLICY)/clipboard_agent/private

#add vendor property
BOARD_SEPOLICY_DIRS += device/intel/sepolicy/vendor/

Expand Down
2 changes: 2 additions & 0 deletions caas/device.mk
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ PRODUCT_COPY_FILES += \

PRODUCT_PACKAGES += vndservicemanager

PRODUCT_PACKAGES += ClipboardAgent

PRODUCT_PACKAGES += \
android.hardware.usb@1.0-impl \
android.hardware.usb@1.0-service \
Expand Down
14 changes: 7 additions & 7 deletions caas/mixins.spec
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ mixinsrel: false
product.mk: device.mk

[groups]
kernel: gmin64(useprebuilt=false,src_path=kernel/lts2020-chromium, loglevel=7, interactive_governor=false, relative_sleepstates=false, modules_in_bootimg=false, external_modules=,debug_modules=, use_bcmdhd=false, use_iwlwifi=false, extmod_platform=bxt, iwl_defconfig=, cfg_path=config-lts/lts2020-chromium, more_modules=true, chromium_src_path=kernel/lts2019-chromium, chromium_cfg_path=config-lts/lts2019-chromium, lts2020_yocto_src_path=kernel/lts2020-yocto, lts2020_yocto_cfg_path=config-lts/lts2020-yocto, lts2020_chromium_src_path=kernel/lts2020-chromium, lts2020_chromium_cfg_path=config-lts/lts2020-chromium)
kernel: gmin64(useprebuilt=false,src_path=kernel/lts2020-chromium, loglevel=8, interactive_governor=false, relative_sleepstates=false, modules_in_bootimg=false, external_modules=,debug_modules=, use_bcmdhd=false, use_iwlwifi=false, extmod_platform=bxt, iwl_defconfig=, cfg_path=config-lts/lts2020-chromium, more_modules=true, chromium_src_path=kernel/lts2019-chromium, chromium_cfg_path=config-lts/lts2019-chromium, lts2020_yocto_src_path=kernel/lts2020-yocto, lts2020_yocto_cfg_path=config-lts/lts2020-yocto, lts2020_chromium_src_path=kernel/lts2020-chromium, lts2020_chromium_cfg_path=config-lts/lts2020-chromium)
disk-bus: auto
boot-arch: project-celadon(uefi_arch=x86_64,fastboot=efi,ignore_rsci=true,disable_watchdog=true,watchdog_parameters=10 30,verity_warning=false,txe_bind_root_of_trust=false,bootloader_block_size=4096,verity_mode=false,disk_encryption=false,file_encryption=true,metadata_encryption=true,fsverity=true,target=caas,ignore_not_applicable_reset=true,self_usb_device_mode_protocol=true,usb_storage=true,live_boot=true,userdata_checkpoint=false)
sepolicy: enforcing
boot-arch: project-celadon(uefi_arch=x86_64,fastboot=efi,ignore_rsci=true,disable_watchdog=true,watchdog_parameters=10 30,verity_warning=false,txe_bind_root_of_trust=false,bootloader_block_size=4096,verity_mode=false,disk_encryption=false,file_encryption=true,metadata_encryption=true,fsverity=true,target=caas,ignore_not_applicable_reset=true,self_usb_device_mode_protocol=true,usb_storage=true,live_boot=true,userdata_checkpoint=false,multi_user_support=true)
sepolicy: permissive
bluetooth: btusb(ivi=false)
audio: project-celadon
vendor-partition: true(partition_size=600,partition_name=vendor)
Expand Down Expand Up @@ -53,9 +53,9 @@ lights: true
power: true(power_throttle=true)
debug-usb-config: true(source_dev=dvcith-0-msc0)
intel_prop: true
trusty: true(ref_target=celadon_64)
trusty: false
memtrack: true
tpm: true
tpm: false
avx: auto
health: hal
slot-ab: true
Expand All @@ -78,8 +78,8 @@ factory-scripts: true
filesystem_config: common
telephony: false
load_modules: true
gptbuild: true(size=32G,generate_craff=false,compress_gptimage=true)
dynamic-partitions: true(super_img_in_flashzip=true,super_partition_size=5000,virtual_ab=true,virtual_ab_compression=true)
gptbuild: true(size=6G,generate_craff=false,compress_gptimage=true)
dynamic-partitions: true(super_img_in_flashzip=true,super_partition_size=5120,virtual_ab=true,virtual_ab_compression=true)
dbc: true
atrace: true
firmware: true(all_firmwares=false)
Expand Down
201 changes: 201 additions & 0 deletions celadon_ivi/cam_sharing/0001-Netlink-sync.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
From 68fe44c6753b4ffa75a43ad07fa29d36cf93c90a Mon Sep 17 00:00:00 2001
From: Neo Fang <neo.fang@intel.com>
Date: Tue, 25 May 2021 15:27:24 +0800
Subject: [PATCH] Netlink sync

Add netlink send/receive in v4l2loopback_open and v4l2loopback_close functions.
When an app tries to open v4l2loopback device node, v4l2loopback_open/close will broadcast
this message thru netlink and wait 750ms for the response.
In design, IntelCameraService(userspace service) will fetch the netlink message and
sendback the response after handled.
---
v4l2loopback.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 109 insertions(+)

diff --git a/v4l2loopback.c b/v4l2loopback.c
index 2e63751..fb6cbf1 100644
--- a/v4l2loopback.c
+++ b/v4l2loopback.c
@@ -36,6 +36,11 @@
#endif
#include <media/v4l2-event.h>

+#include <linux/netlink.h>
+#include <linux/skbuff.h>
+#include <net/sock.h>
+#include <linux/completion.h>
+
#include <linux/miscdevice.h>
#include "v4l2loopback.h"

@@ -63,6 +68,9 @@ MODULE_AUTHOR("Vasily Levin, "
"et al.");
MODULE_LICENSE("GPL");

+struct sock *nl_sk = NULL;
+#define MYMGRP 22
+
/*
* helpers
*/
@@ -458,6 +466,76 @@ struct v4l2l_format {
#define FORMAT_FLAGS_PLANAR 0x01
#define FORMAT_FLAGS_COMPRESSED 0x02

+
+DECLARE_COMPLETION(SyncCompl);
+
+void nl_recv_msg(struct sk_buff *skb) {
+ struct nlmsghdr *nlh = nlmsg_hdr(skb);
+ dprintk(KERN_INFO "Netlink received msg from userspace echo:%s\n", (char *)nlmsg_data(nlh));
+ complete(&SyncCompl);
+}
+
+void nl_send_msg(char *msg) {
+ struct sk_buff *skb_out;
+ struct nlmsghdr *nlh;
+ int res;
+ int msg_size;
+
+ char send_msg[48];
+ unsigned long timeout;
+ unsigned long ret_compl;
+
+ dprintk(KERN_ALERT "THREAD NAME = %s\n", current->comm);
+ if (strncmp(current->comm, "IntelCameraService", strlen(current->comm)) == 0) {
+ return;
+ }
+ memset(send_msg, 0, sizeof(send_msg));
+ sprintf(send_msg, "%d&%s&%s", current->pid, current->comm, msg);
+ msg_size = strlen(send_msg) + 1;
+
+ skb_out = nlmsg_new(
+ NLMSG_ALIGN(msg_size), // @payload: size of the message payload
+ GFP_NOWAIT // @flags: the type of memory to allocate.
+ );
+ if (!skb_out) {
+ printk(KERN_ERR "Failed to allocate new skb\n");
+ return;
+ }
+
+ nlh = nlmsg_put(
+ skb_out, // @skb: socket buffer to store message in
+ 0, // @portid: netlink PORTID of requesting application
+ 0, // @seq: sequence number of message
+ NLMSG_DONE, // @type: message type
+ msg_size, // @payload: length of message payload
+ 0 // @flags: message flags
+ );
+
+ memcpy(nlmsg_data(nlh), send_msg, msg_size);
+ res = nlmsg_multicast(
+ nl_sk, // @sk: netlink socket to spread messages to
+ skb_out, // @skb: netlink message as socket buffer
+ 0, // @portid: own netlink portid to avoid sending to yourself
+ MYMGRP, // @group: multicast group id
+ GFP_NOWAIT // @flags: allocation flags
+ );
+ //msleep(500);
+
+ if (res < 0) {
+ printk(KERN_INFO "Error while sending to user: %d\n", res);
+ } else {
+ dprintk(KERN_INFO "Netlink sent msg to userspace :%s %d\n", send_msg, msg_size);
+ timeout = msecs_to_jiffies(3000);
+ ret_compl = wait_for_completion_timeout(&SyncCompl, timeout);
+ if (ret_compl == 0) {
+ dprintk(KERN_INFO "wait_for_completion_timeout timeout.");
+ }
+ dprintk(KERN_INFO "wait_for_completion_timeout done %lu, %lu", ret_compl, timeout);
+
+ }
+
+}
+
#include "v4l2loopback_formats.h"

static const unsigned int FORMATS = ARRAY_SIZE(formats);
@@ -1978,14 +2056,26 @@ static unsigned int v4l2_loopback_poll(struct file *file,
return ret_mask;
}

+#define PROMPT_OPEN "open&"
+#define PROMPT_CLOSE "close&"
+#define PROMPT_READ "read&"
+#define PROMPT_WRITE "write&"
+
/* do not want to limit device opens, it can be as many readers as user want,
* writers are limited by means of setting writer field */
static int v4l2_loopback_open(struct file *file)
{
struct v4l2_loopback_device *dev;
struct v4l2_loopback_opener *opener;
+ char msg[128];
MARK();
dev = v4l2loopback_getdevice(file);
+
+ memset(msg, 0, sizeof(msg));
+ strcpy(msg, PROMPT_OPEN);
+ strcpy(msg + strlen(PROMPT_OPEN), dev->card_label);
+ nl_send_msg(msg);
+
if (dev->open_count.counter >= dev->max_openers)
return -EBUSY;
/* kfree on close */
@@ -2020,6 +2110,7 @@ static int v4l2_loopback_close(struct file *file)
struct v4l2_loopback_opener *opener;
struct v4l2_loopback_device *dev;
int iswriter = 0;
+ char msg[128];
MARK();

opener = fh_to_opener(file->private_data);
@@ -2042,6 +2133,12 @@ static int v4l2_loopback_close(struct file *file)
if (iswriter) {
dev->ready_for_output = 1;
}
+
+ memset(msg, 0, sizeof(msg));
+ strcpy(msg, PROMPT_CLOSE);
+ strcpy(msg + strlen(PROMPT_CLOSE), dev->card_label);
+ nl_send_msg(msg);
+
MARK();
return 0;
}
@@ -2772,6 +2869,9 @@ static int __init v4l2loopback_init_module(void)
{
int err;
int i;
+ struct netlink_kernel_cfg cfg = {
+ .input = nl_recv_msg,
+ };
MARK();

err = misc_register(&v4l2loopback_misc);
@@ -2856,6 +2956,13 @@ static int __init v4l2loopback_init_module(void)
(V4L2LOOPBACK_VERSION_CODE ) & 0xff);
// clang-format on

+ printk(KERN_INFO "Init NetLink of V4l2Loopback\n");
+ nl_sk = netlink_kernel_create(&init_net, NETLINK_USERSOCK, &cfg);
+ if (!nl_sk) {
+ printk(KERN_ALERT "Error creating socket.\n");
+ goto error;
+ }
+
return 0;
error:
misc_deregister(&v4l2loopback_misc);
@@ -2866,6 +2973,8 @@ error:
static void v4l2loopback_cleanup_module(void)
{
MARK();
+ netlink_kernel_release(nl_sk);
+
/* unregister the device -> it deletes /dev/video* */
free_devices();
/* and get rid of /dev/v4l2loopback */
--
2.25.1

Binary file added celadon_ivi/cam_sharing/IntelCameraService
Binary file not shown.
19 changes: 19 additions & 0 deletions celadon_ivi/cam_sharing/virtualcamera.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Unit]
Description=Virtual Camera Auto Start

After=default.target

[Service]
ExecStartPre=/usr/sbin/modprobe v4l2loopback devices=2 video_nr=6,9 card_label="normal","tobii" exclusive_caps=1,1

ExecStart=/usr/bin/IntelCameraService -i /dev/video0 -o /dev/video6 -o /dev/video9 -w 1920 -h 1080 -f MJPG

SuccessExitStatus=255

Restart=always

RestartSec=10

[Install]
WantedBy=default.target

5 changes: 5 additions & 0 deletions celadon_ivi/device.mk
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ PRODUCT_COPY_FILES += \

PRODUCT_PACKAGES += vndservicemanager

PRODUCT_PACKAGES += ClipboardAgent

PRODUCT_PACKAGES += \
android.hardware.usb@1.0-impl \
android.hardware.usb@1.0-service \
Expand Down Expand Up @@ -302,6 +304,9 @@ PRODUCT_COPY_FILES += vendor/intel/utils/LICENSE:$(PRODUCT_OUT)/LICENSE
PRODUCT_COPY_FILES += $(LOCAL_PATH)/auto_switch_pt_usb_vms.sh:$(PRODUCT_OUT)/scripts/auto_switch_pt_usb_vms.sh
PRODUCT_COPY_FILES += $(LOCAL_PATH)/findall.py:$(PRODUCT_OUT)/scripts/findall.py
PRODUCT_COPY_FILES += $(LOCAL_PATH)/sof_audio/configure_sof.sh:$(PRODUCT_OUT)/scripts/sof_audio/configure_sof.sh
PRODUCT_COPY_FILES += $(LOCAL_PATH)/cam_sharing/0001-Netlink-sync.patch:$(PRODUCT_OUT)/scripts/cam_sharing/0001-Netlink-sync.patch
PRODUCT_COPY_FILES += $(LOCAL_PATH)/cam_sharing/IntelCameraService:$(PRODUCT_OUT)/scripts/cam_sharing/IntelCameraService
PRODUCT_COPY_FILES += $(LOCAL_PATH)/cam_sharing/virtualcamera.service:$(PRODUCT_OUT)/scripts/cam_sharing/virtualcamera.service
PRODUCT_COPY_FILES += $(LOCAL_PATH)/setup_audio_host.sh:$(PRODUCT_OUT)/scripts/setup_audio_host.sh
PRODUCT_COPY_FILES += $(LOCAL_PATH)/guest_pm_control:$(PRODUCT_OUT)/scripts/guest_pm_control
PRODUCT_COPY_FILES += $(LOCAL_PATH)/intel-thermal-conf.xml:$(PRODUCT_OUT)/scripts/intel-thermal-conf.xml
Expand Down