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
45 /* size of camera status notification content */
65 /* identify camera sensor ownership */
73 /* used to switch camera sensor to host */
76 /* used to switch camera sensor to IVSC */
191 hdr->type = ACE_CMD_SET; in init_cmd_hdr()
192 hdr->msg_tgt = ACE_DRV_MSG; in init_cmd_hdr()
193 hdr->init_block = ACE_CMD_INIT_BLOCK; in init_cmd_hdr()
194 hdr->final_block = ACE_CMD_FINAL_BLOCK; in init_cmd_hdr()
200 union ace_cmd_param *param = &cmd->param; in construct_command()
201 struct ace_cmd_hdr *hdr = &cmd->hdr; in construct_command()
205 hdr->cmd_id = cmd_id; in construct_command()
208 param->uuid = ACE_GET_FW_ID_UUID; in construct_command()
209 hdr->param_size = sizeof(param->uuid); in construct_command()
212 param->param = 0; in construct_command()
213 hdr->firmware_id = ace->firmware_id; in construct_command()
214 hdr->param_size = sizeof(param->param); in construct_command()
217 hdr->firmware_id = ace->firmware_id; in construct_command()
220 return -EINVAL; in construct_command()
223 return hdr->param_size + sizeof(cmd->hdr); in construct_command()
230 union ace_notif_hdr *resp_hdr = &ace->cmd_response.hdr; in mei_ace_send()
231 union ace_notif_hdr *ack_hdr = &ace->cmd_ack.hdr; in mei_ace_send()
232 struct ace_cmd_hdr *cmd_hdr = &cmd->hdr; in mei_ace_send()
235 mutex_lock(&ace->lock); in mei_ace_send()
237 reinit_completion(&ace->cmd_completion); in mei_ace_send()
239 ret = mei_cldev_send(ace->cldev, (u8 *)cmd, len); in mei_ace_send()
243 ret = wait_for_completion_killable_timeout(&ace->cmd_completion, in mei_ace_send()
248 ret = -ETIMEDOUT; in mei_ace_send()
252 if (ack_hdr->ack.cmd_id != cmd_hdr->cmd_id) { in mei_ace_send()
253 ret = -EINVAL; in mei_ace_send()
258 ret = ack_hdr->ack.status; in mei_ace_send()
260 ret = -EIO; in mei_ace_send()
267 ret = wait_for_completion_killable_timeout(&ace->cmd_completion, in mei_ace_send()
272 ret = -ETIMEDOUT; in mei_ace_send()
278 if (resp_hdr->response.cmd_id != cmd_hdr->cmd_id) in mei_ace_send()
279 ret = -EINVAL; in mei_ace_send()
282 mutex_unlock(&ace->lock); in mei_ace_send()
328 union ace_notif_hdr *hdr = &resp->hdr; in handle_command_response()
330 switch (hdr->response.cmd_id) { in handle_command_response()
333 memcpy(&ace->cmd_response, resp, len); in handle_command_response()
334 complete(&ace->cmd_completion); in handle_command_response()
346 union ace_notif_hdr *hdr = &ack->hdr; in handle_command_ack()
348 switch (hdr->ack.cmd_id) { in handle_command_ack()
350 ace->firmware_id = ack->cont.firmware_id; in handle_command_ack()
354 memcpy(&ace->cmd_ack, ack, len); in handle_command_ack()
355 complete(&ace->cmd_completion); in handle_command_ack()
372 dev_err(&cldev->dev, "recv error: %d\n", ret); in mei_ace_rx()
376 if (hdr->event.ack) { in mei_ace_rx()
381 switch (hdr->event.event_type) { in mei_ace_rx()
390 dev_dbg(&cldev->dev, "firmware ready\n"); in mei_ace_rx()
399 struct device *dev = &ace->cldev->dev; in mei_ace_setup_dev_link()
405 snprintf(name, sizeof(name), "%s-%pUl", dev_name(dev->parent), &uuid); in mei_ace_setup_dev_link()
407 csi_dev = device_find_child_by_name(dev->parent, name); in mei_ace_setup_dev_link()
409 ret = -EPROBE_DEFER; in mei_ace_setup_dev_link()
414 ace->csi_link = device_link_add(csi_dev, dev, DL_FLAG_PM_RUNTIME | in mei_ace_setup_dev_link()
416 if (!ace->csi_link) { in mei_ace_setup_dev_link()
417 ret = -EINVAL; in mei_ace_setup_dev_link()
422 ace->csi_dev = csi_dev; in mei_ace_setup_dev_link()
433 /* switch camera to host before probe sensor device */
442 dev = &ace->cldev->dev; in mei_ace_post_probe_work()
446 dev_err(dev, "switch camera to host failed: %d\n", ret); in mei_ace_post_probe_work()
450 adev = ACPI_COMPANION(dev->parent); in mei_ace_post_probe_work()
460 struct device *dev = &cldev->dev; in mei_ace_probe()
466 return -ENOMEM; in mei_ace_probe()
468 ace->cldev = cldev; in mei_ace_probe()
469 mutex_init(&ace->lock); in mei_ace_probe()
470 init_completion(&ace->cmd_completion); in mei_ace_probe()
471 INIT_WORK(&ace->work, mei_ace_post_probe_work); in mei_ace_probe()
500 schedule_work(&ace->work); in mei_ace_probe()
512 mutex_destroy(&ace->lock); in mei_ace_probe()
521 cancel_work_sync(&ace->work); in mei_ace_remove()
523 device_link_del(ace->csi_link); in mei_ace_remove()
524 put_device(ace->csi_dev); in mei_ace_remove()
526 pm_runtime_disable(&cldev->dev); in mei_ace_remove()
527 pm_runtime_set_suspended(&cldev->dev); in mei_ace_remove()
531 mutex_destroy(&ace->lock); in mei_ace_remove()