Advertisement
Guest User

RaspiVid.c.patch

a guest
Jul 30th, 2014
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.99 KB | None | 0 0
  1.  
  2. *** RaspiVid.c  2014-07-29 20:21:13.070434559 +0000
  3. --- ../userland/host_applications/linux/apps/raspicam/RaspiVid.c    2014-07-28 11:03:29.787283376 +0000
  4. ***************
  5. *** 75,122 ****
  6.  
  7.   #include <semaphore.h>
  8.  
  9. - #include <bcm2835.h>
  10. - #define BCM2835_GPIO_FSEL_INPT 0
  11. - #define BCM2835_GPIO_FSEL_ALT0 4
  12. -
  13. - void release_i2c_access(void)
  14. - {
  15. -     bcm2835_init();
  16. -     bcm2835_gpio_fsel(0, BCM2835_GPIO_FSEL_INPT);
  17. -     bcm2835_gpio_fsel(1, BCM2835_GPIO_FSEL_INPT);
  18. -     bcm2835_gpio_fsel(28, BCM2835_GPIO_FSEL_INPT);
  19. -     bcm2835_gpio_fsel(29, BCM2835_GPIO_FSEL_INPT);
  20. -     bcm2835_gpio_fsel(28, BCM2835_GPIO_FSEL_ALT3);
  21. -     bcm2835_gpio_set_pud(28, BCM2835_GPIO_PUD_UP);
  22. -     bcm2835_gpio_fsel(29, BCM2835_GPIO_FSEL_ALT3);
  23. -     bcm2835_gpio_set_pud(29, BCM2835_GPIO_PUD_UP);
  24. -
  25. -     uint16_t clk_div = BCM2835_I2C_CLOCK_DIVIDER_2500;
  26. -     uint8_t slave_address = 0x36;
  27. -     bcm2835_i2c_setSlaveAddress(slave_address);
  28. -     bcm2835_i2c_setClockDivider(clk_div);
  29. -     bcm2835_i2c_begin();
  30. -     bcm2835_i2c_end();
  31. - }
  32. -
  33. - void claim_i2c_access(void)
  34. - {
  35. -     bcm2835_init();
  36. -     bcm2835_gpio_fsel(0, BCM2835_GPIO_FSEL_INPT);
  37. -     bcm2835_gpio_fsel(1, BCM2835_GPIO_FSEL_INPT);
  38. -     bcm2835_gpio_fsel(28, BCM2835_GPIO_FSEL_INPT);
  39. -     bcm2835_gpio_fsel(29, BCM2835_GPIO_FSEL_INPT);
  40. -     bcm2835_gpio_fsel(28, BCM2835_GPIO_FSEL_ALT0);
  41. -     bcm2835_gpio_set_pud(28, BCM2835_GPIO_PUD_UP);
  42. -     bcm2835_gpio_fsel(29, BCM2835_GPIO_FSEL_ALT0);
  43. -     bcm2835_gpio_set_pud(29, BCM2835_GPIO_PUD_UP);
  44. -
  45. -     uint16_t clk_div = BCM2835_I2C_CLOCK_DIVIDER_2500;
  46. -     uint8_t slave_address = 0x36;
  47. -     bcm2835_i2c_setSlaveAddress(slave_address);
  48. -     bcm2835_i2c_setClockDivider(clk_div);
  49. - }
  50. -
  51.   /// Camera number to use - we only have one camera, indexed from 0.
  52.   #define CAMERA_NUMBER 0
  53.  
  54. --- 75,80 ----
  55. ***************
  56. *** 1664,1671 ****
  57.    */
  58.   int main(int argc, const char **argv)
  59.   {
  60. -    release_i2c_access();
  61. -
  62.      // Our main data storage vessel..
  63.      RASPIVID_STATE state;
  64.      int exit_code = EX_OK;
  65. --- 1622,1627 ----
  66. ***************
  67. *** 1975,2006 ****
  68.               }
  69.               else
  70.               {
  71. !                while(1) {
  72. !                   char line[80];
  73. !                   char *buffer;
  74. !                   buffer = line;
  75. !                   size_t sz = 80;
  76. !                   fprintf(stderr, "Press just enter to set exposure mode off, or enter 6 hex digits, first 4 are address, next 2 are value.\n");
  77. !                   int r = getline(&buffer, &sz, stdin);
  78. !                   if (r>1){
  79. !                      int x;
  80. !                      sscanf(line,"%x",&x);
  81. !                      int addr = (x&0xFFFF00)>>8;
  82. !                      int val = x & 0xFF;
  83. !                      fprintf(stderr, "set register %x to %x\n", addr, val);
  84. !                      uint8_t data;
  85. !                      char wbuf[4];
  86. !                      wbuf[0] = addr>>8;
  87. !                      wbuf[1] = addr;
  88. !                      wbuf[2] = val;
  89. !                      data = bcm2835_i2c_write(wbuf, 3);
  90. !                      fprintf(stderr,"Write Result = %d\n", data);
  91. !                   } else {
  92. !                      fprintf(stderr, "exposure off, claiming i2c interface\n");
  93. !                      MMAL_PARAMETER_EXPOSUREMODE_T exp_mode = {{MMAL_PARAMETER_EXPOSURE_MODE,sizeof(exp_mode)}, MMAL_PARAM_EXPOSUREMODE_OFF};
  94. !                      mmal_status_to_int(mmal_port_parameter_set(camera_video_port->component->control, &exp_mode.hdr));
  95. !                      claim_i2c_access();
  96. !                   }
  97.                  }
  98.               }
  99.            }
  100. --- 1931,1943 ----
  101.               }
  102.               else
  103.               {
  104. !                if (state.timeout)
  105. !                   vcos_sleep(state.timeout);
  106. !                else
  107. !                {
  108. !                   // timeout = 0 so run forever
  109. !                   while(1)
  110. !                      vcos_sleep(ABORT_INTERVAL);
  111.                  }
  112.               }
  113.            }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement