mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 17:25:35 +03:00
platform: tegra: rtcpu: Add runtime control for camera diagnostics
Add a new sysfs interface that allows toggling camera diagnostics on and off at runtime without deallocating memory resources. This enhances the camera-diagnostics driver functionality by: - Adding a new 'control' sysfs attribute for starting/stopping diagnostics - Implementing intelligent state checking to avoid unnecessary operations - Providing better user feedback about the current diagnostic state - Preserving allocated memory between stop/start cycles The implementation checks if diagnostics are already running or already stopped before attempting state changes, preventing redundant operations and providing informative messages to users. This allows us to run isp-falcon-memtest, which conflicts with camera-diagnostics driver. Jira CAMERASW-32042 Change-Id: I67d0e7e15a25cf000554d1c222b2890be1adce4a Signed-off-by: Mohit Ingale <mohiti@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3330307 GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: Bhushan Rayrikar <brayrikar@nvidia.com> Reviewed-by: Vincent Chung <vincentc@nvidia.com> Reviewed-by: Frank Chen <frankc@nvidia.com>
This commit is contained in:
@@ -1050,12 +1050,119 @@ static void camera_diag_channel_deinit(struct camera_diag_channel *ch)
|
|||||||
dev_dbg(&ch->dev, "Camera diagnostics channel deinitialization complete\n");
|
dev_dbg(&ch->dev, "Camera diagnostics channel deinitialization complete\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the device attribute */
|
/**
|
||||||
|
* @brief Sysfs store function for controlling diagnostic state.
|
||||||
|
*
|
||||||
|
* This function is called when the user writes to the 'control' sysfs attribute.
|
||||||
|
* It allows toggling the ISP SDL diagnostics on and off without deallocating memory.
|
||||||
|
* Accepted values: "start" to start diagnostics, "stop" to stop diagnostics.
|
||||||
|
*
|
||||||
|
* @param[in] dev Device pointer.
|
||||||
|
* @param[in] attr Device attribute descriptor.
|
||||||
|
* @param[in] buf Buffer containing the user command.
|
||||||
|
* @param[in] count Size of the buffer.
|
||||||
|
*
|
||||||
|
* @return Number of bytes processed on success, negative error code on failure.
|
||||||
|
*/
|
||||||
|
static ssize_t control_store(struct device *dev, struct device_attribute *attr,
|
||||||
|
const char *buf, size_t count)
|
||||||
|
{
|
||||||
|
struct camera_diag_channel *ch = dev_get_drvdata(dev);
|
||||||
|
struct camrtc_diag_isp5_sdl_status_resp status;
|
||||||
|
int err = 0;
|
||||||
|
bool is_running = false;
|
||||||
|
|
||||||
|
if (ch == NULL || !ch->is_initialized)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
|
||||||
|
/* Get current status first */
|
||||||
|
err = camera_diag_isp_sdl_status(ch, &status, 0);
|
||||||
|
if (err == 0)
|
||||||
|
is_running = (status.running != 0);
|
||||||
|
|
||||||
|
/* Check for "stop" command */
|
||||||
|
if (strncmp(buf, "stop", 4) == 0) {
|
||||||
|
if (!is_running) {
|
||||||
|
dev_info(&ch->dev, "ISP SDL diagnostics already stopped\n");
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev_info(&ch->dev, "Stopping ISP SDL diagnostics\n");
|
||||||
|
err = camera_diag_isp_sdl_release(ch);
|
||||||
|
if (err != 0) {
|
||||||
|
dev_err(&ch->dev, "Failed to stop ISP SDL diagnostics: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check for "start" command */
|
||||||
|
if (strncmp(buf, "start", 5) == 0) {
|
||||||
|
if (is_running) {
|
||||||
|
dev_info(&ch->dev, "ISP SDL diagnostics already running\n");
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev_info(&ch->dev, "Starting ISP SDL diagnostics\n");
|
||||||
|
err = camera_diag_isp_sdl_setup(ch);
|
||||||
|
if (err != 0) {
|
||||||
|
dev_err(&ch->dev, "Failed to start ISP SDL diagnostics: %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we get here, the command was not recognized */
|
||||||
|
dev_err(&ch->dev, "Unknown command: %.*s\n", (int)count, buf);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sysfs show function for diagnostic control state.
|
||||||
|
*
|
||||||
|
* This function is called when the user reads the 'control' sysfs attribute.
|
||||||
|
* It shows the current state of the ISP SDL diagnostics and available commands.
|
||||||
|
*
|
||||||
|
* @param[in] dev Device pointer.
|
||||||
|
* @param[in] attr Device attribute descriptor.
|
||||||
|
* @param[out] buf Buffer to write the state information to.
|
||||||
|
*
|
||||||
|
* @return Number of bytes written to buffer on success, negative error code on failure.
|
||||||
|
*/
|
||||||
|
static ssize_t control_show(struct device *dev, struct device_attribute *attr, char *buf)
|
||||||
|
{
|
||||||
|
struct camera_diag_channel *ch = dev_get_drvdata(dev);
|
||||||
|
struct camrtc_diag_isp5_sdl_status_resp status;
|
||||||
|
int err;
|
||||||
|
bool is_running = false;
|
||||||
|
|
||||||
|
if (ch == NULL || !ch->is_initialized)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
/* Try to get status for primary ISP instance */
|
||||||
|
err = camera_diag_isp_sdl_status(ch, &status, 0);
|
||||||
|
if (err == 0)
|
||||||
|
is_running = (status.running != 0);
|
||||||
|
|
||||||
|
return sprintf(buf,
|
||||||
|
"Camera diagnostic control\n"
|
||||||
|
"Current state: %s\n"
|
||||||
|
"\n"
|
||||||
|
"Available commands:\n"
|
||||||
|
" start - Start ISP SDL diagnostics\n"
|
||||||
|
" stop - Stop ISP SDL diagnostics\n",
|
||||||
|
is_running ? "RUNNING" : "STOPPED");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create the device attributes */
|
||||||
static DEVICE_ATTR_RO(status);
|
static DEVICE_ATTR_RO(status);
|
||||||
|
static DEVICE_ATTR_RW(control);
|
||||||
|
|
||||||
/* Define the attribute group */
|
/* Define the attribute group */
|
||||||
static struct attribute *camera_diag_attrs[] = {
|
static struct attribute *camera_diag_attrs[] = {
|
||||||
&dev_attr_status.attr,
|
&dev_attr_status.attr,
|
||||||
|
&dev_attr_control.attr,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user