]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/media/dvb-frontends/cxd2880/cxd2880_integ.c
This is the driver for Sony CXD2880 DVB-T2/T tuner + demodulator. It includes the...
[mirror_ubuntu-artful-kernel.git] / drivers / media / dvb-frontends / cxd2880 / cxd2880_integ.c
1 /*
2 * cxd2880_integ.c
3 * Sony CXD2880 DVB-T2/T tuner + demodulator driver
4 * integration layer common functions
5 *
6 * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; version 2 of the License.
11 *
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
15 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, see <http://www.gnu.org/licenses/>.
25 */
26
27 #include "cxd2880_tnrdmd.h"
28 #include "cxd2880_tnrdmd_mon.h"
29 #include "cxd2880_integ.h"
30
31 enum cxd2880_ret cxd2880_integ_init(struct cxd2880_tnrdmd *tnr_dmd)
32 {
33 enum cxd2880_ret ret = CXD2880_RESULT_OK;
34 struct cxd2880_stopwatch timer;
35 u32 elapsed_time = 0;
36 u8 cpu_task_completed = 0;
37
38 if (!tnr_dmd)
39 return CXD2880_RESULT_ERROR_ARG;
40
41 ret = cxd2880_tnrdmd_init1(tnr_dmd);
42 if (ret != CXD2880_RESULT_OK)
43 return ret;
44
45 ret = cxd2880_stopwatch_start(&timer);
46 if (ret != CXD2880_RESULT_OK)
47 return ret;
48
49 while (1) {
50 ret = cxd2880_stopwatch_elapsed(&timer, &elapsed_time);
51 if (ret != CXD2880_RESULT_OK)
52 return ret;
53
54 ret =
55 cxd2880_tnrdmd_check_internal_cpu_status(tnr_dmd,
56 &cpu_task_completed);
57 if (ret != CXD2880_RESULT_OK)
58 return ret;
59
60 if (cpu_task_completed)
61 break;
62
63 if (elapsed_time > CXD2880_TNRDMD_WAIT_INIT_TIMEOUT)
64 return CXD2880_RESULT_ERROR_TIMEOUT;
65 ret =
66 cxd2880_stopwatch_sleep(&timer,
67 CXD2880_TNRDMD_WAIT_INIT_INTVL);
68 if (ret != CXD2880_RESULT_OK)
69 return ret;
70 }
71
72 ret = cxd2880_tnrdmd_init2(tnr_dmd);
73 if (ret != CXD2880_RESULT_OK)
74 return ret;
75
76 return CXD2880_RESULT_OK;
77 }
78
79 enum cxd2880_ret cxd2880_integ_cancel(struct cxd2880_tnrdmd *tnr_dmd)
80 {
81 if (!tnr_dmd)
82 return CXD2880_RESULT_ERROR_ARG;
83
84 cxd2880_atomic_set(&tnr_dmd->cancel, 1);
85
86 return CXD2880_RESULT_OK;
87 }
88
89 enum cxd2880_ret cxd2880_integ_check_cancellation(struct cxd2880_tnrdmd
90 *tnr_dmd)
91 {
92 if (!tnr_dmd)
93 return CXD2880_RESULT_ERROR_ARG;
94
95 if (cxd2880_atomic_read(&tnr_dmd->cancel) != 0)
96 return CXD2880_RESULT_ERROR_CANCEL;
97
98 return CXD2880_RESULT_OK;
99 }