Browse Source

dsp: avtimer: Update function pointers for camera isp to use avtimer

After DLKM, avtimer functions cannot be invoked directly
from kernel driver. Camera driver exposes API to get the
function pointers to use avtimer. Update the function
pointers by calling respective camera set API.
AVTIMER_LEGACY config should be enabled in audio conf
to enable this support.

CRs-Fixed: 2201340
Change-Id: I165e7ea0226e174288f3e8b81ef01fce137e2e35
Signed-off-by: Laxminath Kasam <[email protected]>
Laxminath Kasam 7 years ago
parent
commit
356b68c1e2
1 changed files with 31 additions and 1 deletions
  1. 31 1
      dsp/avtimer.c

+ 31 - 1
dsp/avtimer.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2015, 2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2015, 2017-2018 The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -25,6 +25,9 @@
 #include <linux/of.h>
 #include <linux/wait.h>
 #include <linux/sched.h>
+#if IS_ENABLED(CONFIG_AVTIMER_LEGACY)
+#include <media/msmb_isp.h>
+#endif
 #include <ipc/apr.h>
 #include <dsp/q6core.h>
 
@@ -70,6 +73,7 @@ struct avtimer_t {
 };
 
 static struct avtimer_t avtimer;
+static void avcs_set_isp_fptr(bool enable);
 
 static int32_t aprv2_core_fn_q(struct apr_client_data *data, void *priv)
 {
@@ -313,6 +317,29 @@ int avcs_core_query_timer(uint64_t *avtimer_tick)
 }
 EXPORT_SYMBOL(avcs_core_query_timer);
 
+#if IS_ENABLED(CONFIG_AVTIMER_LEGACY)
+static void avcs_set_isp_fptr(bool enable)
+{
+	struct avtimer_fptr_t av_fptr;
+
+	if (enable) {
+		av_fptr.fptr_avtimer_open = avcs_core_open;
+		av_fptr.fptr_avtimer_enable = avcs_core_disable_power_collapse;
+		av_fptr.fptr_avtimer_get_time = avcs_core_query_timer;
+		msm_isp_set_avtimer_fptr(av_fptr);
+	} else {
+		av_fptr.fptr_avtimer_open = NULL;
+		av_fptr.fptr_avtimer_enable = NULL;
+		av_fptr.fptr_avtimer_get_time = NULL;
+		msm_isp_set_avtimer_fptr(av_fptr);
+	}
+}
+#else
+static void avcs_set_isp_fptr(bool enable)
+{
+}
+#endif
+
 static int avtimer_open(struct inode *inode, struct file *file)
 {
 	return avcs_core_disable_power_collapse(1);
@@ -469,6 +496,8 @@ static int dev_avtimer_probe(struct platform_device *pdev)
 	else
 		avtimer.clk_mult = clk_mult_val;
 
+	avcs_set_isp_fptr(true);
+
 	pr_debug("%s: avtimer.clk_div = %d, avtimer.clk_mult = %d\n",
 		 __func__, avtimer.clk_div, avtimer.clk_mult);
 	return 0;
@@ -500,6 +529,7 @@ static int dev_avtimer_remove(struct platform_device *pdev)
 	cdev_del(&avtimer.myc);
 	class_destroy(avtimer.avtimer_class);
 	unregister_chrdev_region(MKDEV(major, 0), 1);
+	avcs_set_isp_fptr(false);
 
 	return 0;
 }