Lines Matching +full:camera +full:- +full:sensor

1 // SPDX-License-Identifier: GPL-2.0-only
8 * To set ownership of camera sensor, there is specific command, which
9 * is sent via MEI protocol. That's a two-step scheme where the firmware
16 * The power line of camera sensor is directly connected to IVSC instead
17 * of host, when camera sensor ownership is switched to host, sensor is
43 /* size of camera status notification content */
63 /* identify camera sensor ownership */
71 /* used to switch camera sensor to host */
74 /* used to switch camera sensor to IVSC */
189 hdr->type = ACE_CMD_SET; in init_cmd_hdr()
190 hdr->msg_tgt = ACE_DRV_MSG; in init_cmd_hdr()
191 hdr->init_block = ACE_CMD_INIT_BLOCK; in init_cmd_hdr()
192 hdr->final_block = ACE_CMD_FINAL_BLOCK; in init_cmd_hdr()
198 union ace_cmd_param *param = &cmd->param; in construct_command()
199 struct ace_cmd_hdr *hdr = &cmd->hdr; in construct_command()
203 hdr->cmd_id = cmd_id; in construct_command()
206 param->uuid = ACE_GET_FW_ID_UUID; in construct_command()
207 hdr->param_size = sizeof(param->uuid); in construct_command()
210 param->param = 0; in construct_command()
211 hdr->firmware_id = ace->firmware_id; in construct_command()
212 hdr->param_size = sizeof(param->param); in construct_command()
215 hdr->firmware_id = ace->firmware_id; in construct_command()
218 return -EINVAL; in construct_command()
221 return hdr->param_size + sizeof(cmd->hdr); in construct_command()
228 union ace_notif_hdr *resp_hdr = &ace->cmd_response.hdr; in mei_ace_send()
229 union ace_notif_hdr *ack_hdr = &ace->cmd_ack.hdr; in mei_ace_send()
230 struct ace_cmd_hdr *cmd_hdr = &cmd->hdr; in mei_ace_send()
233 mutex_lock(&ace->lock); in mei_ace_send()
235 reinit_completion(&ace->cmd_completion); in mei_ace_send()
237 ret = mei_cldev_send(ace->cldev, (u8 *)cmd, len); in mei_ace_send()
241 ret = wait_for_completion_killable_timeout(&ace->cmd_completion, in mei_ace_send()
246 ret = -ETIMEDOUT; in mei_ace_send()
250 if (ack_hdr->ack.cmd_id != cmd_hdr->cmd_id) { in mei_ace_send()
251 ret = -EINVAL; in mei_ace_send()
256 ret = ack_hdr->ack.status; in mei_ace_send()
258 ret = -EIO; in mei_ace_send()
265 ret = wait_for_completion_killable_timeout(&ace->cmd_completion, in mei_ace_send()
270 ret = -ETIMEDOUT; in mei_ace_send()
276 if (resp_hdr->response.cmd_id != cmd_hdr->cmd_id) in mei_ace_send()
277 ret = -EINVAL; in mei_ace_send()
280 mutex_unlock(&ace->lock); in mei_ace_send()
326 union ace_notif_hdr *hdr = &resp->hdr; in handle_command_response()
328 switch (hdr->response.cmd_id) { in handle_command_response()
331 memcpy(&ace->cmd_response, resp, len); in handle_command_response()
332 complete(&ace->cmd_completion); in handle_command_response()
344 union ace_notif_hdr *hdr = &ack->hdr; in handle_command_ack()
346 switch (hdr->ack.cmd_id) { in handle_command_ack()
348 ace->firmware_id = ack->cont.firmware_id; in handle_command_ack()
352 memcpy(&ace->cmd_ack, ack, len); in handle_command_ack()
353 complete(&ace->cmd_completion); in handle_command_ack()
370 dev_err(&cldev->dev, "recv error: %d\n", ret); in mei_ace_rx()
374 if (hdr->event.ack) { in mei_ace_rx()
379 switch (hdr->event.event_type) { in mei_ace_rx()
388 dev_dbg(&cldev->dev, "firmware ready\n"); in mei_ace_rx()
397 struct device *dev = &ace->cldev->dev; in mei_ace_setup_dev_link()
403 snprintf(name, sizeof(name), "%s-%pUl", dev_name(dev->parent), &uuid); in mei_ace_setup_dev_link()
405 csi_dev = device_find_child_by_name(dev->parent, name); in mei_ace_setup_dev_link()
407 ret = -EPROBE_DEFER; in mei_ace_setup_dev_link()
410 ret = -EPROBE_DEFER; in mei_ace_setup_dev_link()
415 ace->csi_link = device_link_add(csi_dev, dev, DL_FLAG_PM_RUNTIME | in mei_ace_setup_dev_link()
417 if (!ace->csi_link) { in mei_ace_setup_dev_link()
418 ret = -EINVAL; in mei_ace_setup_dev_link()
423 ace->csi_dev = csi_dev; in mei_ace_setup_dev_link()
434 /* switch camera to host before probe sensor device */
443 dev = &ace->cldev->dev; in mei_ace_post_probe_work()
447 dev_err(dev, "switch camera to host failed: %d\n", ret); in mei_ace_post_probe_work()
451 adev = ACPI_COMPANION(dev->parent); in mei_ace_post_probe_work()
461 struct device *dev = &cldev->dev; in mei_ace_probe()
467 return -ENOMEM; in mei_ace_probe()
469 ace->cldev = cldev; in mei_ace_probe()
470 mutex_init(&ace->lock); in mei_ace_probe()
471 init_completion(&ace->cmd_completion); in mei_ace_probe()
472 INIT_WORK(&ace->work, mei_ace_post_probe_work); in mei_ace_probe()
501 schedule_work(&ace->work); in mei_ace_probe()
513 mutex_destroy(&ace->lock); in mei_ace_probe()
522 cancel_work_sync(&ace->work); in mei_ace_remove()
524 device_link_del(ace->csi_link); in mei_ace_remove()
525 put_device(ace->csi_dev); in mei_ace_remove()
527 pm_runtime_disable(&cldev->dev); in mei_ace_remove()
528 pm_runtime_set_suspended(&cldev->dev); in mei_ace_remove()
532 mutex_destroy(&ace->lock); in mei_ace_remove()