linux/drivers/staging/media/atomisp/pci/isp/kernels/wb/wb_1.0/ia_css_wb.host.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0
   2/*
   3 * Support for Intel Camera Imaging ISP subsystem.
   4 * Copyright (c) 2015, Intel Corporation.
   5 *
   6 * This program is free software; you can redistribute it and/or modify it
   7 * under the terms and conditions of the GNU General Public License,
   8 * version 2, as published by the Free Software Foundation.
   9 *
  10 * This program is distributed in the hope it will be useful, but WITHOUT
  11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  13 * more details.
  14 */
  15
  16#include "ia_css_types.h"
  17#include "sh_css_defs.h"
  18#ifndef IA_CSS_NO_DEBUG
  19#include "ia_css_debug.h"
  20#endif
  21#include "sh_css_frac.h"
  22
  23#include "ia_css_wb.host.h"
  24
  25const struct ia_css_wb_config default_wb_config = {
  26        1,
  27        32768,
  28        32768,
  29        32768,
  30        32768
  31};
  32
  33void
  34ia_css_wb_encode(
  35    struct sh_css_isp_wb_params *to,
  36    const struct ia_css_wb_config *from,
  37    unsigned int size)
  38{
  39        (void)size;
  40        to->gain_shift =
  41            uISP_REG_BIT - from->integer_bits;
  42        to->gain_gr =
  43            uDIGIT_FITTING(from->gr, 16 - from->integer_bits,
  44                           to->gain_shift);
  45        to->gain_r =
  46            uDIGIT_FITTING(from->r, 16 - from->integer_bits,
  47                           to->gain_shift);
  48        to->gain_b =
  49            uDIGIT_FITTING(from->b, 16 - from->integer_bits,
  50                           to->gain_shift);
  51        to->gain_gb =
  52            uDIGIT_FITTING(from->gb, 16 - from->integer_bits,
  53                           to->gain_shift);
  54}
  55
  56#ifndef IA_CSS_NO_DEBUG
  57void
  58ia_css_wb_dump(
  59    const struct sh_css_isp_wb_params *wb,
  60    unsigned int level)
  61{
  62        if (!wb) return;
  63        ia_css_debug_dtrace(level, "White Balance:\n");
  64        ia_css_debug_dtrace(level, "\t%-32s = %d\n",
  65                            "wb_gain_shift", wb->gain_shift);
  66        ia_css_debug_dtrace(level, "\t%-32s = %d\n",
  67                            "wb_gain_gr", wb->gain_gr);
  68        ia_css_debug_dtrace(level, "\t%-32s = %d\n",
  69                            "wb_gain_r", wb->gain_r);
  70        ia_css_debug_dtrace(level, "\t%-32s = %d\n",
  71                            "wb_gain_b", wb->gain_b);
  72        ia_css_debug_dtrace(level, "\t%-32s = %d\n",
  73                            "wb_gain_gb", wb->gain_gb);
  74}
  75
  76void
  77ia_css_wb_debug_dtrace(
  78    const struct ia_css_wb_config *config,
  79    unsigned int level)
  80{
  81        ia_css_debug_dtrace(level,
  82                            "config.integer_bits=%d, config.gr=%d, config.r=%d, config.b=%d, config.gb=%d\n",
  83                            config->integer_bits,
  84                            config->gr, config->r,
  85                            config->b, config->gb);
  86}
  87#endif
  88