linux/drivers/media/pci/intel/ivsc/mei_ace.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2023 Intel Corporation. All rights reserved.
 * Intel Visual Sensing Controller ACE Linux driver
 */

/*
 * To set ownership of camera sensor, there is specific command, which
 * is sent via MEI protocol. That's a two-step scheme where the firmware
 * first acks receipt of the command and later responses the command was
 * executed. The command sending function uses "completion" as the
 * synchronization mechanism. The notification for command is received
 * via a mei callback which wakes up the caller. There can be only one
 * outstanding command at a time.
 *
 * The power line of camera sensor is directly connected to IVSC instead
 * of host, when camera sensor ownership is switched to host, sensor is
 * already powered up by firmware.
 */

#include <linux/acpi.h>
#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/mei_cl_bus.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <linux/uuid.h>
#include <linux/workqueue.h>

/* indicating driver message */
#define ACE_DRV_MSG
/* indicating set command */
#define ACE_CMD_SET
/* command timeout determined experimentally */
#define ACE_CMD_TIMEOUT
/* indicating the first command block */
#define ACE_CMD_INIT_BLOCK
/* indicating the last command block */
#define ACE_CMD_FINAL_BLOCK
/* size of camera status notification content */
#define ACE_CAMERA_STATUS_SIZE

/* UUID used to get firmware id */
#define ACE_GET_FW_ID_UUID

/* UUID used to get csi device */
#define MEI_CSI_UUID

/* identify firmware event type */
enum ace_event_type {};

/* identify camera sensor ownership */
enum ace_camera_owner {};

/* identify the command id supported by firmware IPC */
enum ace_cmd_id {};

/* ACE command header structure */
struct ace_cmd_hdr {} __packed;

/* ACE command parameter structure */
ace_cmd_param;

/* ACE command structure */
struct ace_cmd {} __packed;

/* ACE notification header */
ace_notif_hdr;

/* ACE notification content */
ace_notif_cont;

/* ACE notification structure */
struct ace_notif {} __packed;

struct mei_ace {};

static inline void init_cmd_hdr(struct ace_cmd_hdr *hdr)
{}

static int construct_command(struct mei_ace *ace, struct ace_cmd *cmd,
			     enum ace_cmd_id cmd_id)
{}

/* send command to firmware */
static int mei_ace_send(struct mei_ace *ace, struct ace_cmd *cmd,
			size_t len, bool only_ack)
{}

static int ace_set_camera_owner(struct mei_ace *ace,
				enum ace_camera_owner owner)
{}

/* the first command downloaded to firmware */
static inline int ace_get_firmware_id(struct mei_ace *ace)
{}

static void handle_command_response(struct mei_ace *ace,
				    struct ace_notif *resp, int len)
{}

static void handle_command_ack(struct mei_ace *ace,
			       struct ace_notif *ack, int len)
{}

/* callback for receive */
static void mei_ace_rx(struct mei_cl_device *cldev)
{}

static int mei_ace_setup_dev_link(struct mei_ace *ace)
{}

/* switch camera to host before probe sensor device */
static void mei_ace_post_probe_work(struct work_struct *work)
{}

static int mei_ace_probe(struct mei_cl_device *cldev,
			 const struct mei_cl_device_id *id)
{}

static void mei_ace_remove(struct mei_cl_device *cldev)
{}

static int __maybe_unused mei_ace_runtime_suspend(struct device *dev)
{}

static int __maybe_unused mei_ace_runtime_resume(struct device *dev)
{}

static const struct dev_pm_ops mei_ace_pm_ops =;

#define MEI_ACE_UUID

static const struct mei_cl_device_id mei_ace_tbl[] =;
MODULE_DEVICE_TABLE(mei, mei_ace_tbl);

static struct mei_cl_driver mei_ace_driver =;

module_mei_cl_driver();

MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();