linux/drivers/staging/media/atomisp/pci/atomisp_cmd.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/*
   3 * Support for Medifield PNW Camera Imaging ISP subsystem.
   4 *
   5 * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
   6 *
   7 * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
   8 *
   9 * This program is free software; you can redistribute it and/or
  10 * modify it under the terms of the GNU General Public License version
  11 * 2 as published by the Free Software Foundation.
  12 *
  13 * This program is distributed in the hope that it will be useful,
  14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16 * GNU General Public License for more details.
  17 *
  18 *
  19 */
  20
  21#ifndef __ATOMISP_CMD_H__
  22#define __ATOMISP_CMD_H__
  23
  24#include "../../include/linux/atomisp.h"
  25#include <linux/interrupt.h>
  26#include <linux/videodev2.h>
  27
  28#include <media/v4l2-subdev.h>
  29
  30#include "atomisp_internal.h"
  31
  32#include "ia_css_types.h"
  33#include "ia_css.h"
  34
  35struct atomisp_device;
  36struct ia_css_frame;
  37
  38#define MSI_ENABLE_BIT          16
  39#define INTR_DISABLE_BIT        10
  40#define BUS_MASTER_ENABLE       2
  41#define MEMORY_SPACE_ENABLE     1
  42#define INTR_IER                24
  43#define INTR_IIR                16
  44
  45/* ISP2401 */
  46#define RUNMODE_MASK (ATOMISP_RUN_MODE_VIDEO | ATOMISP_RUN_MODE_STILL_CAPTURE \
  47                        | ATOMISP_RUN_MODE_PREVIEW)
  48
  49/* FIXME: check if can go */
  50extern int atomisp_punit_hpll_freq;
  51
  52/*
  53 * Helper function
  54 */
  55void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
  56                  unsigned int size);
  57struct camera_mipi_info *atomisp_to_sensor_mipi_info(struct v4l2_subdev *sd);
  58struct atomisp_video_pipe *atomisp_to_video_pipe(struct video_device *dev);
  59struct atomisp_acc_pipe *atomisp_to_acc_pipe(struct video_device *dev);
  60int atomisp_reset(struct atomisp_device *isp);
  61void atomisp_flush_bufs_and_wakeup(struct atomisp_sub_device *asd);
  62void atomisp_clear_css_buffer_counters(struct atomisp_sub_device *asd);
  63/* ISP2400 */
  64bool atomisp_buffers_queued(struct atomisp_sub_device *asd);
  65/* ISP2401 */
  66bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe);
  67
  68/*
  69 * Interrupt functions
  70 */
  71void atomisp_msi_irq_init(struct atomisp_device *isp);
  72void atomisp_msi_irq_uninit(struct atomisp_device *isp);
  73void atomisp_wdt_work(struct work_struct *work);
  74void atomisp_wdt(struct timer_list *t);
  75void atomisp_setup_flash(struct atomisp_sub_device *asd);
  76irqreturn_t atomisp_isr(int irq, void *dev);
  77irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr);
  78const struct atomisp_format_bridge *get_atomisp_format_bridge_from_mbus(
  79    u32 mbus_code);
  80bool atomisp_is_mbuscode_raw(uint32_t code);
  81int atomisp_get_frame_pgnr(struct atomisp_device *isp,
  82                           const struct ia_css_frame *frame, u32 *p_pgnr);
  83void atomisp_delayed_init_work(struct work_struct *work);
  84
  85/*
  86 * Get internal fmt according to V4L2 fmt
  87 */
  88
  89bool atomisp_is_viewfinder_support(struct atomisp_device *isp);
  90
  91/*
  92 * ISP features control function
  93 */
  94
  95/*
  96 * Function to set sensor runmode by user when
  97 * ATOMISP_IOC_S_SENSOR_RUNMODE ioctl was called
  98 */
  99int atomisp_set_sensor_runmode(struct atomisp_sub_device *asd,
 100                               struct atomisp_s_runmode *runmode);
 101/*
 102 * Function to enable/disable lens geometry distortion correction (GDC) and
 103 * chromatic aberration correction (CAC)
 104 */
 105int atomisp_gdc_cac(struct atomisp_sub_device *asd, int flag,
 106                    __s32 *value);
 107
 108/*
 109 * Function to enable/disable low light mode (including ANR)
 110 */
 111int atomisp_low_light(struct atomisp_sub_device *asd, int flag,
 112                      __s32 *value);
 113
 114/*
 115 * Function to enable/disable extra noise reduction (XNR) in low light
 116 * condition
 117 */
 118int atomisp_xnr(struct atomisp_sub_device *asd, int flag, int *arg);
 119
 120int atomisp_formats(struct atomisp_sub_device *asd, int flag,
 121                    struct atomisp_formats_config *config);
 122
 123/*
 124 * Function to configure noise reduction
 125 */
 126int atomisp_nr(struct atomisp_sub_device *asd, int flag,
 127               struct atomisp_nr_config *config);
 128
 129/*
 130 * Function to configure temporal noise reduction (TNR)
 131 */
 132int atomisp_tnr(struct atomisp_sub_device *asd, int flag,
 133                struct atomisp_tnr_config *config);
 134
 135/*
 136 * Function to configure black level compensation
 137 */
 138int atomisp_black_level(struct atomisp_sub_device *asd, int flag,
 139                        struct atomisp_ob_config *config);
 140
 141/*
 142 * Function to configure edge enhancement
 143 */
 144int atomisp_ee(struct atomisp_sub_device *asd, int flag,
 145               struct atomisp_ee_config *config);
 146
 147/*
 148 * Function to update Gamma table for gamma, brightness and contrast config
 149 */
 150int atomisp_gamma(struct atomisp_sub_device *asd, int flag,
 151                  struct atomisp_gamma_table *config);
 152/*
 153 * Function to update Ctc table for Chroma Enhancement
 154 */
 155int atomisp_ctc(struct atomisp_sub_device *asd, int flag,
 156                struct atomisp_ctc_table *config);
 157
 158/*
 159 * Function to update gamma correction parameters
 160 */
 161int atomisp_gamma_correction(struct atomisp_sub_device *asd, int flag,
 162                             struct atomisp_gc_config *config);
 163
 164/*
 165 * Function to update Gdc table for gdc
 166 */
 167int atomisp_gdc_cac_table(struct atomisp_sub_device *asd, int flag,
 168                          struct atomisp_morph_table *config);
 169
 170/*
 171 * Function to update table for macc
 172 */
 173int atomisp_macc_table(struct atomisp_sub_device *asd, int flag,
 174                       struct atomisp_macc_config *config);
 175/*
 176 * Function to get DIS statistics.
 177 */
 178int atomisp_get_dis_stat(struct atomisp_sub_device *asd,
 179                         struct atomisp_dis_statistics *stats);
 180
 181/*
 182 * Function to get DVS2 BQ resolution settings
 183 */
 184int atomisp_get_dvs2_bq_resolutions(struct atomisp_sub_device *asd,
 185                                    struct atomisp_dvs2_bq_resolutions *bq_res);
 186
 187/*
 188 * Function to set the DIS coefficients.
 189 */
 190int atomisp_set_dis_coefs(struct atomisp_sub_device *asd,
 191                          struct atomisp_dis_coefficients *coefs);
 192
 193/*
 194 * Function to set the DIS motion vector.
 195 */
 196int atomisp_set_dis_vector(struct atomisp_sub_device *asd,
 197                           struct atomisp_dis_vector *vector);
 198
 199/*
 200 * Function to set/get 3A stat from isp
 201 */
 202int atomisp_3a_stat(struct atomisp_sub_device *asd, int flag,
 203                    struct atomisp_3a_statistics *config);
 204
 205/*
 206 * Function to get metadata from isp
 207 */
 208int atomisp_get_metadata(struct atomisp_sub_device *asd, int flag,
 209                         struct atomisp_metadata *config);
 210
 211int atomisp_get_metadata_by_type(struct atomisp_sub_device *asd, int flag,
 212                                 struct atomisp_metadata_with_type *config);
 213
 214int atomisp_set_parameters(struct video_device *vdev,
 215                           struct atomisp_parameters *arg);
 216/*
 217 * Function to set/get isp parameters to isp
 218 */
 219int atomisp_param(struct atomisp_sub_device *asd, int flag,
 220                  struct atomisp_parm *config);
 221
 222/*
 223 * Function to configure color effect of the image
 224 */
 225int atomisp_color_effect(struct atomisp_sub_device *asd, int flag,
 226                         __s32 *effect);
 227
 228/*
 229 * Function to configure bad pixel correction
 230 */
 231int atomisp_bad_pixel(struct atomisp_sub_device *asd, int flag,
 232                      __s32 *value);
 233
 234/*
 235 * Function to configure bad pixel correction params
 236 */
 237int atomisp_bad_pixel_param(struct atomisp_sub_device *asd, int flag,
 238                            struct atomisp_dp_config *config);
 239
 240/*
 241 * Function to enable/disable video image stablization
 242 */
 243int atomisp_video_stable(struct atomisp_sub_device *asd, int flag,
 244                         __s32 *value);
 245
 246/*
 247 * Function to configure fixed pattern noise
 248 */
 249int atomisp_fixed_pattern(struct atomisp_sub_device *asd, int flag,
 250                          __s32 *value);
 251
 252/*
 253 * Function to configure fixed pattern noise table
 254 */
 255int atomisp_fixed_pattern_table(struct atomisp_sub_device *asd,
 256                                struct v4l2_framebuffer *config);
 257
 258/*
 259 * Function to configure false color correction
 260 */
 261int atomisp_false_color(struct atomisp_sub_device *asd, int flag,
 262                        __s32 *value);
 263
 264/*
 265 * Function to configure false color correction params
 266 */
 267int atomisp_false_color_param(struct atomisp_sub_device *asd, int flag,
 268                              struct atomisp_de_config *config);
 269
 270/*
 271 * Function to configure white balance params
 272 */
 273int atomisp_white_balance_param(struct atomisp_sub_device *asd, int flag,
 274                                struct atomisp_wb_config *config);
 275
 276int atomisp_3a_config_param(struct atomisp_sub_device *asd, int flag,
 277                            struct atomisp_3a_config *config);
 278
 279/*
 280 * Function to setup digital zoom
 281 */
 282int atomisp_digital_zoom(struct atomisp_sub_device *asd, int flag,
 283                         __s32 *value);
 284
 285/*
 286 * Function  set camera_prefiles.xml current sensor pixel array size
 287 */
 288int atomisp_set_array_res(struct atomisp_sub_device *asd,
 289                          struct atomisp_resolution  *config);
 290
 291/*
 292 * Function to calculate real zoom region for every pipe
 293 */
 294int atomisp_calculate_real_zoom_region(struct atomisp_sub_device *asd,
 295                                       struct ia_css_dz_config   *dz_config,
 296                                       enum ia_css_pipe_id css_pipe_id);
 297
 298int atomisp_cp_general_isp_parameters(struct atomisp_sub_device *asd,
 299                                      struct atomisp_parameters *arg,
 300                                      struct atomisp_css_params *css_param,
 301                                      bool from_user);
 302
 303int atomisp_cp_lsc_table(struct atomisp_sub_device *asd,
 304                         struct atomisp_shading_table *source_st,
 305                         struct atomisp_css_params *css_param,
 306                         bool from_user);
 307
 308int atomisp_css_cp_dvs2_coefs(struct atomisp_sub_device *asd,
 309                              struct ia_css_dvs2_coefficients *coefs,
 310                              struct atomisp_css_params *css_param,
 311                              bool from_user);
 312
 313int atomisp_cp_morph_table(struct atomisp_sub_device *asd,
 314                           struct atomisp_morph_table *source_morph_table,
 315                           struct atomisp_css_params *css_param,
 316                           bool from_user);
 317
 318int atomisp_cp_dvs_6axis_config(struct atomisp_sub_device *asd,
 319                                struct atomisp_dvs_6axis_config *user_6axis_config,
 320                                struct atomisp_css_params *css_param,
 321                                bool from_user);
 322
 323int atomisp_makeup_css_parameters(struct atomisp_sub_device *asd,
 324                                  struct atomisp_parameters *arg,
 325                                  struct atomisp_css_params *css_param);
 326
 327int atomisp_compare_grid(struct atomisp_sub_device *asd,
 328                         struct atomisp_grid_info *atomgrid);
 329
 330int atomisp_get_sensor_mode_data(struct atomisp_sub_device *asd,
 331                                 struct atomisp_sensor_mode_data *config);
 332
 333int atomisp_get_fmt(struct video_device *vdev, struct v4l2_format *f);
 334
 335/* This function looks up the closest available resolution. */
 336int atomisp_try_fmt(struct video_device *vdev, struct v4l2_format *f,
 337                    bool *res_overflow);
 338
 339int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f);
 340int atomisp_set_fmt_file(struct video_device *vdev, struct v4l2_format *f);
 341
 342int atomisp_set_shading_table(struct atomisp_sub_device *asd,
 343                              struct atomisp_shading_table *shading_table);
 344
 345int atomisp_offline_capture_configure(struct atomisp_sub_device *asd,
 346                                      struct atomisp_cont_capture_conf *cvf_config);
 347
 348int atomisp_ospm_dphy_down(struct atomisp_device *isp);
 349int atomisp_ospm_dphy_up(struct atomisp_device *isp);
 350int atomisp_exif_makernote(struct atomisp_sub_device *asd,
 351                           struct atomisp_makernote_info *config);
 352
 353void atomisp_free_internal_buffers(struct atomisp_sub_device *asd);
 354
 355int atomisp_s_ae_window(struct atomisp_sub_device *asd,
 356                        struct atomisp_ae_window *arg);
 357
 358int  atomisp_flash_enable(struct atomisp_sub_device *asd,
 359                          int num_frames);
 360
 361int atomisp_freq_scaling(struct atomisp_device *vdev,
 362                         enum atomisp_dfs_mode mode,
 363                         bool force);
 364
 365void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
 366                      enum ia_css_buffer_type buf_type,
 367                      enum ia_css_pipe_id css_pipe_id,
 368                      bool q_buffers, enum atomisp_input_stream_id stream_id);
 369
 370void atomisp_css_flush(struct atomisp_device *isp);
 371int atomisp_source_pad_to_stream_id(struct atomisp_sub_device *asd,
 372                                    uint16_t source_pad);
 373
 374/*
 375 * Events. Only one event has to be exported for now.
 376 */
 377void atomisp_eof_event(struct atomisp_sub_device *asd, uint8_t exp_id);
 378
 379enum mipi_port_id __get_mipi_port(struct atomisp_device *isp,
 380                                  enum atomisp_camera_port port);
 381
 382bool atomisp_is_vf_pipe(struct atomisp_video_pipe *pipe);
 383
 384void atomisp_apply_css_parameters(
 385    struct atomisp_sub_device *asd,
 386    struct atomisp_css_params *css_param);
 387void atomisp_free_css_parameters(struct atomisp_css_params *css_param);
 388
 389void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe);
 390
 391void atomisp_flush_params_queue(struct atomisp_video_pipe *asd);
 392/*
 393 * Function to do Raw Buffer related operation, after enable Lock Unlock Raw Buffer
 394 */
 395int atomisp_exp_id_unlock(struct atomisp_sub_device *asd, int *exp_id);
 396int atomisp_exp_id_capture(struct atomisp_sub_device *asd, int *exp_id);
 397
 398/*
 399 * Function to update Raw Buffer bitmap
 400 */
 401int atomisp_set_raw_buffer_bitmap(struct atomisp_sub_device *asd, int exp_id);
 402void atomisp_init_raw_buffer_bitmap(struct atomisp_sub_device *asd);
 403
 404/*
 405 * Function to enable/disable zoom for capture pipe
 406 */
 407int atomisp_enable_dz_capt_pipe(struct atomisp_sub_device *asd,
 408                                unsigned int *enable);
 409
 410/*
 411 * Function to get metadata type bu pipe id
 412 */
 413enum atomisp_metadata_type
 414atomisp_get_metadata_type(struct atomisp_sub_device *asd,
 415                          enum ia_css_pipe_id pipe_id);
 416
 417/*
 418 * Function for HAL to inject a fake event to wake up poll thread
 419 */
 420int atomisp_inject_a_fake_event(struct atomisp_sub_device *asd, int *event);
 421
 422/*
 423 * Function for HAL to query how many invalid frames at the beginning of ISP
 424 * pipeline output
 425 */
 426int atomisp_get_invalid_frame_num(struct video_device *vdev,
 427                                  int *invalid_frame_num);
 428
 429int atomisp_mrfld_power_up(struct atomisp_device *isp);
 430int atomisp_mrfld_power_down(struct atomisp_device *isp);
 431int atomisp_runtime_suspend(struct device *dev);
 432int atomisp_runtime_resume(struct device *dev);
 433#endif /* __ATOMISP_CMD_H__ */
 434