linux/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/debug_private.h
<<
>>
Prefs
   1/*
   2 * Support for Intel Camera Imaging ISP subsystem.
   3 * Copyright (c) 2010-2015, Intel Corporation.
   4 *
   5 * This program is free software; you can redistribute it and/or modify it
   6 * under the terms and conditions of the GNU General Public License,
   7 * version 2, as published by the Free Software Foundation.
   8 *
   9 * This program is distributed in the hope it will be useful, but WITHOUT
  10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  12 * more details.
  13 */
  14
  15#ifndef __DEBUG_PRIVATE_H_INCLUDED__
  16#define __DEBUG_PRIVATE_H_INCLUDED__
  17
  18#include "debug_public.h"
  19
  20#include "sp.h"
  21
  22#define __INLINE_ISP__
  23#include "isp.h"
  24
  25#include "memory_access.h"
  26
  27#include "assert_support.h"
  28
  29STORAGE_CLASS_DEBUG_C bool is_debug_buffer_empty(void)
  30{
  31        return (debug_data_ptr->head == debug_data_ptr->tail);
  32}
  33
  34STORAGE_CLASS_DEBUG_C hrt_data debug_dequeue(void)
  35{
  36        hrt_data value = 0;
  37
  38        assert(debug_buffer_address != ((hrt_address)-1));
  39
  40        debug_synch_queue();
  41
  42        if (!is_debug_buffer_empty()) {
  43                value = debug_data_ptr->buf[debug_data_ptr->head];
  44                debug_data_ptr->head = (debug_data_ptr->head + 1) & DEBUG_BUF_MASK;
  45                sp_dmem_store_uint32(SP0_ID, debug_buffer_address + DEBUG_DATA_HEAD_ADDR, debug_data_ptr->head);
  46        }
  47
  48        return value;
  49}
  50
  51STORAGE_CLASS_DEBUG_C void debug_synch_queue(void)
  52{
  53        uint32_t remote_tail = sp_dmem_load_uint32(SP0_ID, debug_buffer_address + DEBUG_DATA_TAIL_ADDR);
  54/* We could move the remote head after the upload, but we would have to limit the upload w.r.t. the local head. This is easier */
  55        if (remote_tail > debug_data_ptr->tail) {
  56                size_t  delta = remote_tail - debug_data_ptr->tail;
  57                sp_dmem_load(SP0_ID, debug_buffer_address + DEBUG_DATA_BUF_ADDR + debug_data_ptr->tail*sizeof(uint32_t), (void *)&(debug_data_ptr->buf[debug_data_ptr->tail]), delta*sizeof(uint32_t));
  58        } else if (remote_tail < debug_data_ptr->tail) {
  59                size_t  delta = DEBUG_BUF_SIZE - debug_data_ptr->tail;
  60                sp_dmem_load(SP0_ID, debug_buffer_address + DEBUG_DATA_BUF_ADDR + debug_data_ptr->tail*sizeof(uint32_t), (void *)&(debug_data_ptr->buf[debug_data_ptr->tail]), delta*sizeof(uint32_t));
  61                sp_dmem_load(SP0_ID, debug_buffer_address + DEBUG_DATA_BUF_ADDR, (void *)&(debug_data_ptr->buf[0]), remote_tail*sizeof(uint32_t));
  62        } /* else we are up to date */
  63        debug_data_ptr->tail = remote_tail;
  64}
  65
  66STORAGE_CLASS_DEBUG_C void debug_synch_queue_isp(void)
  67{
  68        uint32_t remote_tail = isp_dmem_load_uint32(ISP0_ID, DEBUG_BUFFER_ISP_DMEM_ADDR + DEBUG_DATA_TAIL_ADDR);
  69/* We could move the remote head after the upload, but we would have to limit the upload w.r.t. the local head. This is easier */
  70        if (remote_tail > debug_data_ptr->tail) {
  71                size_t  delta = remote_tail - debug_data_ptr->tail;
  72                isp_dmem_load(ISP0_ID, DEBUG_BUFFER_ISP_DMEM_ADDR + DEBUG_DATA_BUF_ADDR + debug_data_ptr->tail*sizeof(uint32_t), (void *)&(debug_data_ptr->buf[debug_data_ptr->tail]), delta*sizeof(uint32_t));
  73        } else if (remote_tail < debug_data_ptr->tail) {
  74                size_t  delta = DEBUG_BUF_SIZE - debug_data_ptr->tail;
  75                isp_dmem_load(ISP0_ID, DEBUG_BUFFER_ISP_DMEM_ADDR + DEBUG_DATA_BUF_ADDR + debug_data_ptr->tail*sizeof(uint32_t), (void *)&(debug_data_ptr->buf[debug_data_ptr->tail]), delta*sizeof(uint32_t));
  76                isp_dmem_load(ISP0_ID, DEBUG_BUFFER_ISP_DMEM_ADDR + DEBUG_DATA_BUF_ADDR, (void *)&(debug_data_ptr->buf[0]), remote_tail*sizeof(uint32_t));
  77        } /* else we are up to date */
  78        debug_data_ptr->tail = remote_tail;
  79}
  80
  81STORAGE_CLASS_DEBUG_C void debug_synch_queue_ddr(void)
  82{
  83        uint32_t        remote_tail;
  84
  85        mmgr_load(debug_buffer_ddr_address + DEBUG_DATA_TAIL_DDR_ADDR, &remote_tail, sizeof(uint32_t));
  86/* We could move the remote head after the upload, but we would have to limit the upload w.r.t. the local head. This is easier */
  87        if (remote_tail > debug_data_ptr->tail) {
  88                size_t  delta = remote_tail - debug_data_ptr->tail;
  89                mmgr_load(debug_buffer_ddr_address + DEBUG_DATA_BUF_DDR_ADDR + debug_data_ptr->tail*sizeof(uint32_t), (void *)&(debug_data_ptr->buf[debug_data_ptr->tail]), delta*sizeof(uint32_t));
  90        } else if (remote_tail < debug_data_ptr->tail) {
  91                size_t  delta = DEBUG_BUF_SIZE - debug_data_ptr->tail;
  92                mmgr_load(debug_buffer_ddr_address + DEBUG_DATA_BUF_DDR_ADDR + debug_data_ptr->tail*sizeof(uint32_t), (void *)&(debug_data_ptr->buf[debug_data_ptr->tail]), delta*sizeof(uint32_t));
  93                mmgr_load(debug_buffer_ddr_address + DEBUG_DATA_BUF_DDR_ADDR, (void *)&(debug_data_ptr->buf[0]), remote_tail*sizeof(uint32_t));
  94        } /* else we are up to date */
  95        debug_data_ptr->tail = remote_tail;
  96}
  97
  98#endif /* __DEBUG_PRIVATE_H_INCLUDED__ */
  99
 100