3 * Sony CXD2880 DVB-T2/T tuner + demodulator driver
4 * integration layer common functions
6 * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
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.
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.
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/>.
27 #include "cxd2880_tnrdmd.h"
28 #include "cxd2880_tnrdmd_mon.h"
29 #include "cxd2880_integ.h"
31 enum cxd2880_ret
cxd2880_integ_init(struct cxd2880_tnrdmd
*tnr_dmd
)
33 enum cxd2880_ret ret
= CXD2880_RESULT_OK
;
34 struct cxd2880_stopwatch timer
;
36 u8 cpu_task_completed
= 0;
39 return CXD2880_RESULT_ERROR_ARG
;
41 ret
= cxd2880_tnrdmd_init1(tnr_dmd
);
42 if (ret
!= CXD2880_RESULT_OK
)
45 ret
= cxd2880_stopwatch_start(&timer
);
46 if (ret
!= CXD2880_RESULT_OK
)
50 ret
= cxd2880_stopwatch_elapsed(&timer
, &elapsed_time
);
51 if (ret
!= CXD2880_RESULT_OK
)
55 cxd2880_tnrdmd_check_internal_cpu_status(tnr_dmd
,
57 if (ret
!= CXD2880_RESULT_OK
)
60 if (cpu_task_completed
)
63 if (elapsed_time
> CXD2880_TNRDMD_WAIT_INIT_TIMEOUT
)
64 return CXD2880_RESULT_ERROR_TIMEOUT
;
66 cxd2880_stopwatch_sleep(&timer
,
67 CXD2880_TNRDMD_WAIT_INIT_INTVL
);
68 if (ret
!= CXD2880_RESULT_OK
)
72 ret
= cxd2880_tnrdmd_init2(tnr_dmd
);
73 if (ret
!= CXD2880_RESULT_OK
)
76 return CXD2880_RESULT_OK
;
79 enum cxd2880_ret
cxd2880_integ_cancel(struct cxd2880_tnrdmd
*tnr_dmd
)
82 return CXD2880_RESULT_ERROR_ARG
;
84 cxd2880_atomic_set(&tnr_dmd
->cancel
, 1);
86 return CXD2880_RESULT_OK
;
89 enum cxd2880_ret
cxd2880_integ_check_cancellation(struct cxd2880_tnrdmd
93 return CXD2880_RESULT_ERROR_ARG
;
95 if (cxd2880_atomic_read(&tnr_dmd
->cancel
) != 0)
96 return CXD2880_RESULT_ERROR_CANCEL
;
98 return CXD2880_RESULT_OK
;