void
VideoProducer::Connect(status_t error, const media_source& source,
	const media_destination& destination, const media_format& format,
	char* _name)
{
	FUNCTION("Connect() %ldx%ld\n",
		format.u.raw_video.display.line_width,
		format.u.raw_video.display.line_count);

	if (fConnected) {
		ERROR("Connect() - already connected.\n");
		return;
	}

	if (source != fOutput.source) {
		ERROR("Connect() - wrong source.\n");
		return;
	}
	if (error != B_OK) {
		ERROR("Connect() - consumer error: %s\n", strerror(error));
		return;
	}
	if (!const_cast<media_format*>(&format)->Matches(&fOutput.format)) {
		ERROR("Connect() - format mismatch.\n");
		return;
	}

	fOutput.destination = destination;
	strcpy(_name, fOutput.name);
	fConnectedFormat = format.u.raw_video;
	fBufferDuration = 20000;

	if (fConnectedFormat.field_rate != 0.0f) {
		fPerformanceTimeBase = fPerformanceTimeBase
			+ (bigtime_t)((fFrame - fFrameBase)
				* 1000000LL / fConnectedFormat.field_rate);
		fFrameBase = fFrame;
		fBufferDuration = bigtime_t(1000000LL / fConnectedFormat.field_rate);
	}

	if (fConnectedFormat.display.bytes_per_row == 0) {
		ERROR("Connect() - connected format still has BPR wildcard!\n");
		fConnectedFormat.display.bytes_per_row
			= 4 * fConnectedFormat.display.line_width;
	}

	// Create the buffer group
	if (fUsedBufferGroup == NULL) {
		fBufferGroup = new BBufferGroup(fConnectedFormat.display.bytes_per_row
			* fConnectedFormat.display.line_count, BUFFER_COUNT);
		status_t err = fBufferGroup->InitCheck();
		if (err < B_OK) {
			delete fBufferGroup;
			fBufferGroup = NULL;
			ERROR("Connect() - buffer group error: %s\n", strerror(err));
			return;
		}
		fUsedBufferGroup = fBufferGroup;
	}

	// get the latency
	fBufferLatency = (BUFFER_COUNT - 1) * fBufferDuration;

	int32 bufferCount;
	if (fUsedBufferGroup->CountBuffers(&bufferCount) == B_OK) {
		// recompute the latency
		fBufferLatency = (bufferCount - 1) * fBufferDuration;
	}

	bigtime_t latency = 0;
	media_node_id tsID = 0;
	FindLatencyFor(fOutput.destination, &latency, &tsID);
	SetEventLatency(latency + fBufferLatency);

	fConnected = true;
	fEnabled = true;

	// Tell frame generation thread to recalculate delay value
	release_sem(fFrameSync);
}
Beispiel #2
0
double
FUNCTION(gsl_stats,wabsdev) (const BASE w[], const size_t wstride, const BASE data[], const size_t stride, const size_t n)
{
  const double wmean = FUNCTION(gsl_stats,wmean)(w, wstride, data, stride, n);
  return FUNCTION(gsl_stats,wabsdev_m)(w, wstride, data, stride, n, wmean);
}
Beispiel #3
0
	"gpio86", "gpio87", "gpio88", "gpio89", "gpio90"
};
static const char * const tsif1_groups[] = {
	"gpio82", "gpio83", "gpio84", "gpio85", "gpio86"
};
static const char * const tsif2_groups[] = {
	"gpio91", "gpio95", "gpio96", "gpio97", "gpio101"
};
static const char * const uim_groups[] = {
	"gpio130", "gpio131", "gpio132", "gpio133"
};
static const char * const uim_batt_alarm_groups[] = {
	"gpio102"
};
static const struct msm_function apq8084_functions[] = {
	FUNCTION(adsp_ext),
	FUNCTION(audio_ref),
	FUNCTION(blsp_i2c1),
	FUNCTION(blsp_i2c2),
	FUNCTION(blsp_i2c3),
	FUNCTION(blsp_i2c4),
	FUNCTION(blsp_i2c5),
	FUNCTION(blsp_i2c6),
	FUNCTION(blsp_i2c7),
	FUNCTION(blsp_i2c8),
	FUNCTION(blsp_i2c9),
	FUNCTION(blsp_i2c10),
	FUNCTION(blsp_i2c11),
	FUNCTION(blsp_i2c12),
	FUNCTION(blsp_spi1),
	FUNCTION(blsp_spi1_cs1),
Beispiel #4
0
void
FUNCTION (test, func) (const size_t M, const size_t N)
{
  TYPE (gsl_vector) * v;
  size_t i, j;
  size_t k = 0;

  TYPE (gsl_matrix) * m = FUNCTION (gsl_matrix, alloc) (M, N);

  gsl_test (m->data == 0, NAME (gsl_matrix) "_alloc returns valid pointer");
  gsl_test (m->size1 != M, NAME (gsl_matrix) "_alloc returns valid size1");
  gsl_test (m->size2 != N, NAME (gsl_matrix) "_alloc returns valid size2");
  gsl_test (m->tda != N, NAME (gsl_matrix) "_alloc returns valid tda");

  for (i = 0; i < M; i++)
    {
      for (j = 0; j < N; j++)
        {
          k++;
          FUNCTION (gsl_matrix, set) (m, i, j, (BASE) k);
        }
    }

  {
    status = 0;
    k = 0;
    for (i = 0; i < M; i++)
      {
        for (j = 0; j < N; j++)
          {
            k++;
            if (m->data[i * N + j] != (BASE) k)
              status = 1;
          };
      };

    gsl_test (status, NAME (gsl_matrix) "_set writes into array");
  }

  {
    status = 0;
    k = 0;
    for (i = 0; i < M; i++)
      {
        for (j = 0; j < N; j++)
          {
            k++;
            if (FUNCTION (gsl_matrix, get) (m, i, j) != (BASE) k)
              status = 1;
          };
      };
    gsl_test (status, NAME (gsl_matrix) "_get reads from array");
  }


  FUNCTION (gsl_matrix, free) (m);      /* free whatever is in m */

  m = FUNCTION (gsl_matrix, calloc) (M, N);
  v = FUNCTION (gsl_vector, calloc) (N);

  {
    int status = (FUNCTION(gsl_matrix,isnull)(m) != 1);
    TEST (status, "_isnull" DESC " on calloc matrix");
    
    status = (FUNCTION(gsl_matrix,ispos)(m) != 0);
    TEST (status, "_ispos" DESC " on calloc matrix");
    
    status = (FUNCTION(gsl_matrix,isneg)(m) != 0);
    TEST (status, "_isneg" DESC " on calloc matrix");

    status = (FUNCTION(gsl_matrix,isnonneg)(m) != 1);
    TEST (status, "_isnonneg" DESC " on calloc matrix");
  }


  k = 0;
  for (i = 0; i < M; i++)
    {
      for (j = 0; j < N; j++)
        {
          k++;
          FUNCTION (gsl_matrix, set) (m, i, j, (BASE) k);
        }
    }


  {
    status = 0;
    k = 0;
    for (i = 0; i < M; i++)
      {
        FUNCTION (gsl_matrix, get_row) (v, m, i);

        for (j = 0; j < N; j++)
          {
            k++;
            if (v->data[j] != (BASE) k)
              status = 1;
          }
      }

    gsl_test (status, NAME (gsl_matrix) "_get_row extracts row");
  }

  {
    BASE exp_max = FUNCTION(gsl_matrix, get) (m, 0, 0);
    BASE exp_min = FUNCTION(gsl_matrix, get) (m, 0, 0);
    size_t exp_imax = 0, exp_jmax = 0, exp_imin = 0, exp_jmin = 0;

    for (i = 0; i < M; i++)
      {
        for (j = 0; j < N; j++)
          {
            BASE k = FUNCTION(gsl_matrix, get) (m, i, j);
            if (k > exp_max) {
              exp_max =  FUNCTION(gsl_matrix, get) (m, i, j);
              exp_imax = i;
              exp_jmax = j;
            }
            if (k < exp_min) {
              exp_min =  FUNCTION(gsl_matrix, get) (m, i, j);
              exp_imin = i;
              exp_jmin = j;
            }
          }
      }

    {
      BASE max = FUNCTION(gsl_matrix, max) (m) ;

      gsl_test (max != exp_max, NAME(gsl_matrix) "_max returns correct maximum value");
    }

    {
      BASE min = FUNCTION(gsl_matrix, min) (m) ;
      
      gsl_test (min != exp_min, NAME(gsl_matrix) "_min returns correct minimum value");
    }

    {
      BASE min, max;
      FUNCTION(gsl_matrix, minmax) (m, &min, &max);

      gsl_test (max != exp_max, NAME(gsl_matrix) "_minmax returns correct maximum value");
      gsl_test (min != exp_min, NAME(gsl_matrix) "_minmax returns correct minimum value");
    }


    {
      size_t imax, jmax;
      FUNCTION(gsl_matrix, max_index) (m, &imax, &jmax) ;

      gsl_test (imax != exp_imax, NAME(gsl_matrix) "_max_index returns correct maximum i");
      gsl_test (jmax != exp_jmax, NAME(gsl_matrix) "_max_index returns correct maximum j");
    }

    {
      size_t imin, jmin;
      FUNCTION(gsl_matrix, min_index) (m, &imin, &jmin) ;

      gsl_test (imin != exp_imin, NAME(gsl_matrix) "_min_index returns correct minimum i");
      gsl_test (jmin != exp_jmin, NAME(gsl_matrix) "_min_index returns correct minimum j");
    }

    {
      size_t imin, jmin, imax, jmax;

      FUNCTION(gsl_matrix, minmax_index) (m,  &imin, &jmin, &imax, &jmax);

      gsl_test (imax != exp_imax, NAME(gsl_matrix) "_minmax_index returns correct maximum i");
      gsl_test (jmax != exp_jmax, NAME(gsl_matrix) "_minmax_index returns correct maximum j");

      gsl_test (imin != exp_imin, NAME(gsl_matrix) "_minmax_index returns correct minimum i");
      gsl_test (jmin != exp_jmin, NAME(gsl_matrix) "_minmax_index returns correct minimum j");
    }

#if FP
    FUNCTION(gsl_matrix,set)(m, 2, 3, GSL_NAN);
    exp_min = GSL_NAN; exp_max = GSL_NAN;
    exp_imin = 2; exp_jmin = 3;
    exp_imax = 2; exp_jmax = 3;

    {
      BASE max = FUNCTION(gsl_matrix, max) (m) ;

      gsl_test_abs (max,exp_max, 0, NAME(gsl_matrix) "_max returns correct maximum value for NaN");
    }

    {
      BASE min = FUNCTION(gsl_matrix, min) (m) ;
      
      gsl_test_abs (min, exp_min, 0, NAME(gsl_matrix) "_min returns correct minimum value for NaN");
    }

    {
      BASE min, max;
      FUNCTION(gsl_matrix, minmax) (m, &min, &max);

      gsl_test_abs (max, exp_max, 0, NAME(gsl_matrix) "_minmax returns correct maximum value for NaN");
      gsl_test_abs (min, exp_min, 0, NAME(gsl_matrix) "_minmax returns correct minimum value for NaN");
    }


    {
      size_t imax, jmax;
      FUNCTION(gsl_matrix, max_index) (m, &imax, &jmax) ;

      gsl_test (imax != exp_imax, NAME(gsl_matrix) "_max_index returns correct maximum i for NaN");
      gsl_test (jmax != exp_jmax, NAME(gsl_matrix) "_max_index returns correct maximum j for NaN");
    }

    {
      size_t imin, jmin;
      FUNCTION(gsl_matrix, min_index) (m, &imin, &jmin) ;

      gsl_test (imin != exp_imin, NAME(gsl_matrix) "_min_index returns correct minimum i for NaN");
      gsl_test (jmin != exp_jmin, NAME(gsl_matrix) "_min_index returns correct minimum j for NaN");
    }

    {
      size_t imin, jmin, imax, jmax;

      FUNCTION(gsl_matrix, minmax_index) (m,  &imin, &jmin, &imax, &jmax);

      gsl_test (imax != exp_imax, NAME(gsl_matrix) "_minmax_index returns correct maximum i for NaN");
      gsl_test (jmax != exp_jmax, NAME(gsl_matrix) "_minmax_index returns correct maximum j for NaN");

      gsl_test (imin != exp_imin, NAME(gsl_matrix) "_minmax_index returns correct minimum i for NaN");
      gsl_test (jmin != exp_jmin, NAME(gsl_matrix) "_minmax_index returns correct minimum j for NaN");
    }
#endif 


  }


  for (i = 0; i < M; i++)
    {
      for (j = 0; j < N; j++)
        {
          FUNCTION (gsl_matrix, set) (m, i, j, (ATOMIC) 0);
        }
    }

  {
    status = (FUNCTION(gsl_matrix,isnull)(m) != 1);
    TEST (status, "_isnull" DESC " on null matrix") ;

    status = (FUNCTION(gsl_matrix,ispos)(m) != 0);
    TEST (status, "_ispos" DESC " on null matrix") ;

    status = (FUNCTION(gsl_matrix,isneg)(m) != 0);
    TEST (status, "_isneg" DESC " on null matrix") ;

    status = (FUNCTION(gsl_matrix,isnonneg)(m) != 1);
    TEST (status, "_isnonneg" DESC " on null matrix") ;
  }


  k = 0;
  for (i = 0; i < M; i++)
    {
      for (j = 0; j < N; j++)
        {
          k++;
          FUNCTION (gsl_matrix, set) (m, i, j, (ATOMIC) (k % 10));
        }
    }

  {
    status = (FUNCTION(gsl_matrix,isnull)(m) != 0);
    TEST (status, "_isnull" DESC " on non-negative matrix") ;

    status = (FUNCTION(gsl_matrix,ispos)(m) != 0);
    TEST (status, "_ispos" DESC " on non-negative matrix") ;

    status = (FUNCTION(gsl_matrix,isneg)(m) != 0);
    TEST (status, "_isneg" DESC " on non-negative matrix") ;

    status = (FUNCTION(gsl_matrix,isnonneg)(m) != 1);
    TEST (status, "_isnonneg" DESC " on non-negative matrix") ;
  }

#ifndef UNSIGNED
  k = 0;
  for (i = 0; i < M; i++)
    {
      for (j = 0; j < N; j++)
        {
          ATOMIC mij = ((++k) % 10)  - (ATOMIC) 5;
          FUNCTION (gsl_matrix, set) (m, i, j, mij);
        }
    }

  {
    status = (FUNCTION(gsl_matrix,isnull)(m) != 0);
    TEST (status, "_isnull" DESC " on mixed matrix") ;

    status = (FUNCTION(gsl_matrix,ispos)(m) != 0);
    TEST (status, "_ispos" DESC " on mixed matrix") ;

    status = (FUNCTION(gsl_matrix,isneg)(m) != 0);
    TEST (status, "_isneg" DESC " on mixed matrix") ;

    status = (FUNCTION(gsl_matrix,isnonneg)(m) != 0);
    TEST (status, "_isnonneg" DESC " on mixed matrix") ;
  }

  k = 0;
  for (i = 0; i < M; i++)
    {
      for (j = 0; j < N; j++)
        {
          k++;
          FUNCTION (gsl_matrix, set) (m, i, j, -(ATOMIC) (k % 10));
        }
    }

  {
    status = (FUNCTION(gsl_matrix,isnull)(m) != 0);
    TEST (status, "_isnull" DESC " on non-positive matrix") ;

    status = (FUNCTION(gsl_matrix,ispos)(m) != 0);
    TEST (status, "_ispos" DESC " on non-positive matrix") ;

    status = (FUNCTION(gsl_matrix,isneg)(m) != 0);
    TEST (status, "_isneg" DESC " on non-positive matrix") ;

    status = (FUNCTION(gsl_matrix,isnonneg)(m) != 0);
    TEST (status, "_isnonneg" DESC " on non-positive matrix") ;
  }
#endif

  k = 0;
  for (i = 0; i < M; i++)
    {
      for (j = 0; j < N; j++)
        {
          k++;
          FUNCTION (gsl_matrix, set) (m, i, j, (ATOMIC) (k % 10 + 1));
        }
    }

  {
    status = (FUNCTION(gsl_matrix,isnull)(m) != 0);
    TEST (status, "_isnull" DESC " on positive matrix") ;

    status = (FUNCTION(gsl_matrix,ispos)(m) != 1);
    TEST (status, "_ispos" DESC " on positive matrix") ;

    status = (FUNCTION(gsl_matrix,isneg)(m) != 0);
    TEST (status, "_isneg" DESC " on positive matrix") ;

    status = (FUNCTION(gsl_matrix,isnonneg)(m) != 1);
    TEST (status, "_isnonneg" DESC " on positive matrix") ;
  }

#if (!defined(UNSIGNED) && !defined(BASE_CHAR))
  k = 0;
  for (i = 0; i < M; i++)
    {
      for (j = 0; j < N; j++)
        {
          k++;
          FUNCTION (gsl_matrix, set) (m, i, j, -(ATOMIC) (k % 10 + 1));
        }
    }

  {
    status = (FUNCTION(gsl_matrix,isnull)(m) != 0);
    TEST (status, "_isnull" DESC " on negative matrix") ;

    status = (FUNCTION(gsl_matrix,ispos)(m) != 0);
    TEST (status, "_ispos" DESC " on negative matrix") ;

    status = (FUNCTION(gsl_matrix,isneg)(m) != 1);
    TEST (status, "_isneg" DESC " on negative matrix") ;

    status = (FUNCTION(gsl_matrix,isnonneg)(m) != 0);
    TEST (status, "_isnonneg" DESC " on negative matrix") ;
  }
#endif

  FUNCTION (gsl_matrix, free) (m);
  FUNCTION (gsl_vector, free) (v);
}
Beispiel #5
0
void
FUNCTION (test, binary_noncontiguous) (const size_t M, const size_t N)
{
  TYPE (gsl_matrix) * l = FUNCTION (gsl_matrix, calloc) (M+1, N+1);
  VIEW (gsl_matrix, view) m = FUNCTION (gsl_matrix, submatrix) (l, 0, 0, M, N);

  size_t i, j;
  size_t k = 0;

  char filename[] = "test.XXXXXX";
#if !defined( _MSC_VER )
  int fd = mkstemp(filename);
#else
  char * fd = _mktemp(filename);
# define fdopen fopen
#endif

  {
    FILE *f = fdopen(fd, "wb");
    k = 0;
    for (i = 0; i < M; i++)
      {
        for (j = 0; j < N; j++)
          {
            k++;
            FUNCTION (gsl_matrix, set) (&m.matrix, i, j, (BASE) k);
          }
      }

    FUNCTION (gsl_matrix, fwrite) (f, &m.matrix);
    fclose (f);
  }

  {
    FILE *f = fopen (filename, "rb");
    TYPE (gsl_matrix) * ll = FUNCTION (gsl_matrix, alloc) (M+1, N+1);
    VIEW (gsl_matrix, view) mm = FUNCTION (gsl_matrix, submatrix) (ll, 0, 0, M, N);
    status = 0;

    FUNCTION (gsl_matrix, fread) (f, &mm.matrix);
    k = 0;
    for (i = 0; i < M; i++)
      {
        for (j = 0; j < N; j++)
          {
            k++;
            if (FUNCTION (gsl_matrix, get) (&mm.matrix, i, j) != (BASE) k)
              status = 1;
          }
      }

    gsl_test (status, NAME (gsl_matrix) "_write and read (noncontiguous)");

    fclose (f);
    FUNCTION (gsl_matrix, free) (ll);
  }

  unlink(filename);

  FUNCTION (gsl_matrix, free) (l);
}
Beispiel #6
0
};

static const char * const icllp_spi0_groups[] = { "spi0_grp" };
static const char * const icllp_spi1_groups[] = { "spi1_grp" };
static const char * const icllp_spi2_groups[] = { "spi2_grp" };
static const char * const icllp_i2c0_groups[] = { "i2c0_grp" };
static const char * const icllp_i2c1_groups[] = { "i2c1_grp" };
static const char * const icllp_i2c2_groups[] = { "i2c2_grp" };
static const char * const icllp_i2c3_groups[] = { "i2c3_grp" };
static const char * const icllp_i2c4_groups[] = { "i2c4_grp" };
static const char * const icllp_uart0_groups[] = { "uart0_grp" };
static const char * const icllp_uart1_groups[] = { "uart1_grp" };
static const char * const icllp_uart2_groups[] = { "uart2_grp" };

static const struct intel_function icllp_functions[] = {
	FUNCTION("spi0", icllp_spi0_groups),
	FUNCTION("spi1", icllp_spi1_groups),
	FUNCTION("spi2", icllp_spi2_groups),
	FUNCTION("i2c0", icllp_i2c0_groups),
	FUNCTION("i2c1", icllp_i2c1_groups),
	FUNCTION("i2c2", icllp_i2c2_groups),
	FUNCTION("i2c3", icllp_i2c3_groups),
	FUNCTION("i2c4", icllp_i2c4_groups),
	FUNCTION("uart0", icllp_uart0_groups),
	FUNCTION("uart1", icllp_uart1_groups),
	FUNCTION("uart2", icllp_uart2_groups),
};

static const struct intel_pinctrl_soc_data icllp_soc_data = {
	.pins = icllp_pins,
	.npins = ARRAY_SIZE(icllp_pins),
Beispiel #7
0
{
	return (display.flag.update_acceleration);
}

// *************************************************************************************************
// User navigation ( [____] = default menu item after reset )
//
//	LINE1: 	[Time] -> Alarm -> Temperature -> Altitude -> Heart rate -> Speed -> Acceleration
//
//	LINE2: 	[Date] -> Stopwatch -> Battery  -> ACC -> PPT -> SYNC -> Calories/Distance --> RFBSL
// *************************************************************************************************

// Line1 - Time
const struct menu menu_L1_Time =
{
	FUNCTION(sx_time),			// direct function
	FUNCTION(mx_time),			// sub menu function
	FUNCTION(display_time),		// display function
	FUNCTION(update_time),		// new display data
	&menu_L1_Alarm,
};
// Line1 - Alarm
const struct menu menu_L1_Alarm =
{
	FUNCTION(sx_alarm),			// direct function
	FUNCTION(mx_alarm),			// sub menu function
	FUNCTION(display_alarm),	// display function
	FUNCTION(update_alarm),		// new display data
	&menu_L1_Temperature,
};
// Line1 - Temperature
Beispiel #8
0
status_t
DirEntryTree::LookupEntry(const char* name, uint64& _blockIndex)
{
	FUNCTION("name: \"%s\"\n", name);

	status_t error = _InitReadOnly();
	if (error != B_OK)
		RETURN_ERROR(error);

	size_t nameLength = strlen(name);
	if (nameLength > kCheckSumFSNameLength)
		RETURN_ERROR(B_ENTRY_NOT_FOUND);

	uint32 depth = _Depth();

	DirEntryBlock entryBlock(fRootEntryBlock, fRootEntryBlockSize);
ASSERT(entryBlock.Check());

	Block block;

	for (uint32 level = 0; level <= depth; level++) {
		if (entryBlock.EntryCount() == 0)
			RETURN_ERROR(level == 0 ? B_ENTRY_NOT_FOUND : B_BAD_DATA);

		bool exactMatch;
		int32 index = entryBlock.FindInsertionIndex(name, nameLength,
			exactMatch);

		// If we haven't found an exact match, the index points to the first
		// entry that is greater or after the last entry.
		if (!exactMatch) {
			if (index == 0) {
				// The first entry is already greater, so the branch doesn't
				// contain the entry we're looking for.
				RETURN_ERROR(B_ENTRY_NOT_FOUND);
			}

			index--;
		}

		PRINT("  level %" B_PRId32 " -> index: %" B_PRId32 " %sexact\n", level,
			index, exactMatch ? "" : " not ");

		uint64 blockIndex = entryBlock.BlockIndexAt(index);

		if (level == depth) {
			// final level -- here we should have an exact match
			if (!exactMatch)
				RETURN_ERROR(B_ENTRY_NOT_FOUND);

			_blockIndex = blockIndex;
			return B_OK;
		}

		// not the final level -- load the block and descend to the next
		// level
		if (!block.GetReadable(fDirectory->GetVolume(), blockIndex))
			RETURN_ERROR(B_ERROR);

		entryBlock.SetTo((checksumfs_dir_entry_block*)block.Data(),
			B_PAGE_SIZE);
ASSERT(entryBlock.Check());
	}

	// cannot get here, but keep the compiler happy
	RETURN_ERROR(B_ENTRY_NOT_FOUND);
}
Beispiel #9
0
status_t
DirEntryTree::LookupNextEntry(const char* name, char* foundName,
	size_t& _foundNameLength, uint64& _blockIndex)
{
	FUNCTION("name: \"%s\"\n", name);

	status_t error = _InitReadOnly();
	if (error != B_OK)
		RETURN_ERROR(error);

	size_t nameLength = strlen(name);
	if (nameLength > kCheckSumFSNameLength)
		RETURN_ERROR(B_ENTRY_NOT_FOUND);

	int32 depth = _Depth();

	LevelInfo* infos = new(std::nothrow) LevelInfo[
		kCheckSumFSMaxDirEntryTreeDepth + 1];
	if (infos == NULL)
		RETURN_ERROR(B_NO_MEMORY);
	ArrayDeleter<LevelInfo> infosDeleter(infos);

	infos[0].entryBlock.SetTo(fRootEntryBlock, fRootEntryBlockSize);
ASSERT(infos[0].entryBlock.Check());

	// descend the tree
	for (int32 level = 0; level <= depth; level++) {
		LevelInfo& info = infos[level];

		if (info.entryBlock.EntryCount() == 0) {
			if (level == 0) {
				// directory is empty
				return B_ENTRY_NOT_FOUND;
			}

			RETURN_ERROR(B_BAD_DATA);
		}

		info.index = info.entryBlock.FindInsertionIndex(name, nameLength,
			info.exactMatch);

		PRINT("  level %" B_PRId32 " -> index: %" B_PRId32 " %sexact\n", level,
			info.index, info.exactMatch ? "" : " not ");

		if (level == depth)
			break;

		// If we haven't found an exact match, the index points to the first
		// entry that is greater or after the last entry.
		if (!info.exactMatch && info.index > 0)
			info.index--;

		uint64 nextBlockIndex = info.entryBlock.BlockIndexAt(info.index);

		// not the final level -- load the block and descend to the next
		// level
		LevelInfo& nextInfo = infos[level + 1];
		if (!nextInfo.block.GetReadable(fDirectory->GetVolume(),
				nextBlockIndex)) {
			RETURN_ERROR(B_ERROR);
		}

		nextInfo.entryBlock.SetTo(
			(checksumfs_dir_entry_block*)nextInfo.block.Data(),
			B_PAGE_SIZE);
ASSERT(nextInfo.entryBlock.Check());
	}

	if (infos[depth].exactMatch)
		infos[depth].index++;

	if (infos[depth].index >= infos[depth].entryBlock.EntryCount()) {
		// We're at the end of the last block -- we need to track back to find a
		// greater branch.
		PRINT("  searching for greater branch\n");

		int32 level;
		for (level = depth - 1; level >= 0; level--) {
			LevelInfo& info = infos[level];
			if (++info.index < info.entryBlock.EntryCount()) {
				PRINT("  found greater branch: level: %" B_PRId32 " -> index: %"
					B_PRId32 "\n", level, info.index);
				break;
			}
		}

		if (level < 0)
			return B_ENTRY_NOT_FOUND;

		// We've found a greater branch -- get the first entry in that branch.
		for (level++; level <= depth; level++) {
			LevelInfo& previousInfo = infos[level - 1];
			LevelInfo& info = infos[level];

			uint64 nextBlockIndex = previousInfo.entryBlock.BlockIndexAt(
				previousInfo.index);

			// load the block
			if (!info.block.GetReadable(fDirectory->GetVolume(),
					nextBlockIndex)) {
				RETURN_ERROR(B_ERROR);
			}

			info.entryBlock.SetTo(
				(checksumfs_dir_entry_block*)info.block.Data(), B_PAGE_SIZE);
ASSERT(info.entryBlock.Check());

			info.index = 0;
			if (info.entryBlock.EntryCount() == 0)
				RETURN_ERROR(B_BAD_DATA);
		}
	}

	// get and check the name
	LevelInfo& info = infos[depth];

	name = info.entryBlock.NameAt(info.index, nameLength);
	if (nameLength > kCheckSumFSNameLength
		|| strnlen(name, nameLength) != nameLength) {
		RETURN_ERROR(B_BAD_DATA);
	}

	// set the return values
	memcpy(foundName, name, nameLength);
	foundName[nameLength] = '\0';
	_foundNameLength = nameLength;
	_blockIndex = info.entryBlock.BlockIndexAt(info.index);

	PRINT("  found entry: \"%s\" -> %" B_PRIu64 "\n", foundName, _blockIndex);

	return B_OK;
}
Beispiel #10
0
};

static const char * const audio_ref_clk_groups[] = { "gpio69" };

static const char * const bt_groups[] = { "gpio35", "gpio43", "gpio44" };

static const char * const fm_groups[] = { "gpio41", "gpio42" };

static const char * const wlan_groups[] = {
	"gpio36", "gpio37", "gpio38", "gpio39", "gpio40"
};

static const char * const slimbus_groups[] = { "gpio70", "gpio71" };

static const struct msm_function msm8x74_functions[] = {
	FUNCTION(gpio),
	FUNCTION(cci_i2c0),
	FUNCTION(cci_i2c1),
	FUNCTION(uim1),
	FUNCTION(uim2),
	FUNCTION(uim_batt_alarm),
	FUNCTION(blsp_uim1),
	FUNCTION(blsp_uim2),
	FUNCTION(blsp_uim3),
	FUNCTION(blsp_uim4),
	FUNCTION(blsp_uim5),
	FUNCTION(blsp_uim6),
	FUNCTION(blsp_uim7),
	FUNCTION(blsp_uim8),
	FUNCTION(blsp_uim9),
	FUNCTION(blsp_uim10),
Beispiel #11
0
status_t
DirEntryTree::_UpdateOrInsertKey(LevelInfo* infos, int32 level,
	const char* name, size_t nameLength, uint64 blockIndex, bool insertKey,
	Transaction& transaction)
{
	FUNCTION("level: %" B_PRId32 ": %s name: \"%.*s\" (%" B_PRIuSIZE "), "
		"blockIndex: %" B_PRIu64 "\n", level, insertKey ? "insert" : "update",
		(int)nameLength, name, nameLength, blockIndex);

	// Some temporary blocks: newBlock is used when a block is split. The
	// other three are used when a key update respectively insertion in the
	// parent block becomes necessary. We only need them, since the name
	// we update/insert is potentially from a block and instead of cloning
	// the name, we simple postpone putting the block until we don't need
	// the name anymore.
	Block newBlock;
	Block tempBlockUpdate;
	Block tempBlockUpdateInsert;
	Block tempBlockInsert;

	int32 depth = _Depth();
	status_t error;

	bool updateNextKey = !insertKey;
	bool insertNextKey = insertKey;
	const char* nameToUpdate = name;
	size_t nameToUpdateLength = nameLength;
	const char* nextNameToInsert = name;
	size_t nextNameToInsertLength = nameLength;
	uint64 nextBlockIndexToInsert = blockIndex;

	for (; level >= 0; level--) {
		LevelInfo& info = infos[level];

		bool updateThisKey = updateNextKey;
		bool insertThisKey = insertNextKey;

		if (!updateThisKey && !insertThisKey)
			return B_OK;

		updateNextKey = false;
		insertNextKey = false;

		blockIndex = nextBlockIndexToInsert;
		name = nextNameToInsert;
		nameLength = nextNameToInsertLength;

		// make the block writable
		if (level > 0) {
			error = info.block.MakeWritable(transaction);
			if (error != B_OK)
				RETURN_ERROR(error);
		}

		if (updateThisKey) {
			PRINT("  level: %" B_PRId32 ", index: %" B_PRId32 ": updating key "
				"to \"%.*s\" (%" B_PRIuSIZE ")\n", level, info.index,
				(int)nameToUpdateLength, nameToUpdate, nameToUpdateLength);

			size_t oldNameLength;
			info.entryBlock.NameAt(info.index, oldNameLength);
			size_t spaceNeeded = oldNameLength < nameToUpdateLength
				? nameToUpdateLength - oldNameLength : 0;

			if (spaceNeeded <= info.entryBlock.FreeSpace()) {
				info.entryBlock.ReplaceEntryName(info.index, nameToUpdate,
					nameToUpdateLength);
				if (info.index == 0) {
					// we updated at index 0, so we need to update this
					// block's key in the parent block
					updateNextKey = true;
					nameToUpdate = info.entryBlock.NameAt(0,
						nameToUpdateLength);

					// make sure the new block is kept until we no longer
					// use the name in the next iteration
					tempBlockUpdate.TransferFrom(info.block);
				}
			} else if (level == 0) {
				// We need to split the root block -- clone it first.
				error = _InsertEntryIncrementDepth(infos, transaction);
				if (error != B_OK)
					RETURN_ERROR(error);

				level = 2;
					// _InsertEntryIncrementDepth() moved the root block
					// content to level 1, where we want to continue.
				updateNextKey = true;
				insertNextKey = insertThisKey;
				continue;
			} else {
				// We need to split this non-root block.
				int32 splitIndex;
				error = _InsertEntrySplitBlock(level, info, spaceNeeded,
					transaction, newBlock, splitIndex);
				if (error != B_OK)
					RETURN_ERROR(error);

				nextBlockIndexToInsert = newBlock.Index();

				DirEntryBlock newEntryBlock(
					(checksumfs_dir_entry_block*)newBlock.Data(),
					B_PAGE_SIZE);
ASSERT(newEntryBlock.Check());

				if (info.index < splitIndex) {
					ASSERT(info.entryBlock.FreeSpace() >= spaceNeeded);

					info.entryBlock.ReplaceEntryName(info.index,
						nameToUpdate, nameToUpdateLength);
					if (info.index == 0) {
						// we updated at index 0, so we need to update this
						// block's key in the parent block
						updateNextKey = true;
						nameToUpdate = info.entryBlock.NameAt(0,
							nameToUpdateLength);

						// make sure the new block is kept until we no
						// longer use the name in the next iteration
						tempBlockUpdate.TransferFrom(info.block);
					}
				} else {
					ASSERT(newEntryBlock.FreeSpace() >= spaceNeeded);

					// we need to transfer the block to the info, in case we
					// also need to insert a key below
					info.block.TransferFrom(newBlock);
					info.entryBlock.SetTo(
						(checksumfs_dir_entry_block*)info.block.Data(),
						B_PAGE_SIZE);
ASSERT(info.entryBlock.Check());

					info.index -= splitIndex;

					info.entryBlock.ReplaceEntryName(info.index, nameToUpdate,
						nameToUpdateLength);
				}

				// the newly created block needs to be inserted in the
				// parent
				insertNextKey = true;
				nextNameToInsert = newEntryBlock.NameAt(0,
					nextNameToInsertLength);

				// make sure the new block is kept until we no longer use
				// the name in the next iteration (might already have been
				// transferred to entry.block)
				tempBlockUpdateInsert.TransferFrom(newBlock);
			}
		}

		if (insertThisKey) {
			// insert after the block we descended
			if (level < depth)
				info.index++;

			PRINT("  level: %" B_PRId32 ", index: %" B_PRId32 ": inserting key "
				"\"%.*s\" (%" B_PRIuSIZE "), blockIndex: %" B_PRIu64 "\n",
				level, info.index, (int)nameLength, name, nameLength,
				blockIndex);

			if (info.entryBlock.FreeSpace() >= nameLength + 10) {
				info.entryBlock.InsertEntry(info.index, name,
					nameLength, blockIndex);
				if (info.index == 0) {
					// we inserted at index 0, so we need to update this
					// block's key in the parent block
					updateNextKey = true;
					nameToUpdate = info.entryBlock.NameAt(0,
						nameToUpdateLength);

					// make sure the new block is kept until we no longer
					// use the name in the next iteration
					tempBlockUpdate.TransferFrom(info.block);
				}
				continue;
			}

			// Not enough space left in the block -- we need to split it.
			ASSERT(!insertNextKey);

			// for level == 0 we need to clone the block first
			if (level == 0) {
				error = _InsertEntryIncrementDepth(infos, transaction);
				if (error != B_OK)
					RETURN_ERROR(error);

				level = 2;
					// _InsertEntryIncrementDepth() moved the root block
					// content to level 1, where we want to continue.
				updateNextKey = false;
				insertNextKey = true;
				continue;
			}

			int32 splitIndex;
			error = _InsertEntrySplitBlock(level, info, nameLength + 10,
				transaction, newBlock, splitIndex);
			if (error != B_OK)
				RETURN_ERROR(error);

			DirEntryBlock newEntryBlock(
				(checksumfs_dir_entry_block*)newBlock.Data(),
				B_PAGE_SIZE);
ASSERT(newEntryBlock.Check());

			if (info.index < splitIndex) {
				ASSERT(info.entryBlock.FreeSpace() >= nameLength + 10);

				info.entryBlock.InsertEntry(info.index, name,
					nameLength, blockIndex);
				if (info.index == 0) {
					// we inserted at index 0, so we need to update this
					// block's key in the parent block
					updateNextKey = true;
					nameToUpdate = info.entryBlock.NameAt(0,
						nameToUpdateLength);

					// make sure the new block is kept until we no longer
					// use the name in the next iteration
					tempBlockUpdate.TransferFrom(info.block);
				}
			} else {
				ASSERT(newEntryBlock.FreeSpace() >= nameLength + 10);

				info.index -= splitIndex;

				newEntryBlock.InsertEntry(info.index, name, nameLength,
					blockIndex);
			}

			// the newly created block needs to be inserted in the parent
			insertNextKey = true;
			nextNameToInsert = newEntryBlock.NameAt(0, nextNameToInsertLength);
			nextBlockIndexToInsert = newBlock.Index();

			// make sure the new block is kept until we no longer use
			// the name in the next iteration
			tempBlockInsert.TransferFrom(newBlock);
		}
	}

	return B_OK;
}
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

int
FUNCTION (gsl_vector, fread) (FILE * stream, TYPE (gsl_vector) * v)
{
  int status = FUNCTION (gsl_block, raw_fread) (stream,
                                                v->data,
                                                v->size,
                                                v->stride);
  return status;
}

int
FUNCTION (gsl_vector, fwrite) (FILE * stream, const TYPE (gsl_vector) * v)
{
  int status = FUNCTION (gsl_block, raw_fwrite) (stream,
                                                 v->data,
                                                 v->size,
                                                 v->stride);
  return status;
}

#if !(defined(USES_LONGDOUBLE) && !defined(HAVE_PRINTF_LONGDOUBLE))
Beispiel #13
0
	"gpio20",
	"gpio22", "gpio23", "gpio24", "gpio25",
	"gpio26", "gpio27", "gpio28", "gpio29",
	"gpio30", "gpio31", "gpio32", "gpio33",
	"gpio34"
};

#define FUNCTION(_name, _gr)					\
	{							\
		.name = #_name,					\
		.groups = oxnas_##_gr##_group,			\
		.ngroups = ARRAY_SIZE(oxnas_##_gr##_group),	\
	}

static const struct oxnas_function oxnas_functions[] = {
	FUNCTION(gpio, fct0),
	FUNCTION(fct3, fct3),
};

#define OXNAS_PINCTRL_GROUP(_pin, _name, ...)				\
	{								\
		.name = #_name,						\
		.pin = _pin,						\
		.bank = _pin / PINS_PER_BANK,				\
		.functions = (struct oxnas_desc_function[]){		\
			__VA_ARGS__, { } },				\
	}

#define OXNAS_PINCTRL_FUNCTION(_name, _fct)		\
	{						\
		.name = #_name,				\
static const char * const sptlp_spi1_groups[] = { "spi0_grp" };
static const char * const sptlp_uart0_groups[] = { "uart0_grp" };
static const char * const sptlp_uart1_groups[] = { "uart1_grp" };
static const char * const sptlp_uart2_groups[] = { "uart2_grp" };
static const char * const sptlp_i2c0_groups[] = { "i2c0_grp" };
static const char * const sptlp_i2c1_groups[] = { "i2c1_grp" };
static const char * const sptlp_i2c2_groups[] = { "i2c2_grp" };
static const char * const sptlp_i2c3_groups[] = { "i2c3_grp" };
static const char * const sptlp_i2c4_groups[] = { "i2c4_grp", "i2c4b_grp" };
static const char * const sptlp_i2c5_groups[] = { "i2c5_grp" };
static const char * const sptlp_ssp2_groups[] = { "ssp2_grp" };
static const char * const sptlp_emmc_groups[] = { "emmc_grp" };
static const char * const sptlp_sd_groups[] = { "sd_grp" };

static const struct intel_function sptlp_functions[] = {
	FUNCTION("spi0", sptlp_spi0_groups),
	FUNCTION("spi1", sptlp_spi1_groups),
	FUNCTION("uart0", sptlp_uart0_groups),
	FUNCTION("uart1", sptlp_uart1_groups),
	FUNCTION("uart2", sptlp_uart2_groups),
	FUNCTION("i2c0", sptlp_i2c0_groups),
	FUNCTION("i2c1", sptlp_i2c1_groups),
	FUNCTION("i2c2", sptlp_i2c2_groups),
	FUNCTION("i2c3", sptlp_i2c3_groups),
	FUNCTION("i2c4", sptlp_i2c4_groups),
	FUNCTION("i2c5", sptlp_i2c5_groups),
	FUNCTION("ssp2", sptlp_ssp2_groups),
	FUNCTION("emmc", sptlp_emmc_groups),
	FUNCTION("sd", sptlp_sd_groups),
};
Beispiel #15
0
char PcdComMF522(uint8_t   Command,
		uint8_t *pIn ,
		uint8_t   InLenByte,
		uint8_t *pOut ,
		uint8_t *pOutLenBit)
{
	FUNCTION() ;
	char   status = TAG_ERR;
	uint8_t   irqEn   = 0x00;
	uint8_t   waitFor = 0x00;
	uint8_t   lastBits;
	uint8_t   n;
	uint32_t   i;
	uint8_t PcdErr;

	//	printf("CMD %02x\n",pIn[0]);
	switch (Command)
	{
	case PCD_AUTHENT:
		irqEn   = 0x12;
		waitFor = 0x10;
		break;
	case PCD_TRANSCEIVE:
		irqEn   = 0x77;
		waitFor = 0x30;
		break;
	default:
		break;
	}

	WriteRawRC(ComIEnReg,irqEn|0x80);
	//	WriteRawRC(ComIEnReg,irqEn);
	ClearBitMask(ComIrqReg,0x80);
	SetBitMask(FIFOLevelReg,0x80);
	WriteRawRC(CommandReg,PCD_IDLE);

	for (i=0; i<InLenByte; i++) {
		WriteRawRC(FIFODataReg, pIn [i]);
	}

	WriteRawRC(CommandReg, Command);

	if (Command == PCD_TRANSCEIVE) {
		SetBitMask(BitFramingReg,0x80);
	}

	//i = 600;//���ʱ��Ƶ�ʵ������M1�����ȴ�ʱ��25ms
	i = 150;
	do
	{
		usleep(200);
		//		bcm2835_delayMicroseconds(200);
		n = ReadRawRC(ComIrqReg);
		i--;
	}
	while ((i!=0) && (!(n&0x01)) && (!(n&waitFor)));

	ClearBitMask(BitFramingReg,0x80);

	if (i!=0)
	{
		PcdErr=ReadRawRC(ErrorReg);
		if (!(PcdErr & 0x11))
		{
			status = TAG_OK;
			if (n & irqEn & 0x01) {status = TAG_NOTAG;}
			if (Command == PCD_TRANSCEIVE) {
				n = ReadRawRC(FIFOLevelReg);
				lastBits = ReadRawRC(ControlReg) & 0x07;
				if (lastBits) {*pOutLenBit = (n-1)*8 + lastBits;}
				else {*pOutLenBit = n*8;}

				if (n == 0) {n = 1;}
				if (n > MAXRLEN) {n = MAXRLEN;}

				for (i=0; i<n; i++) {
					pOut [i] = ReadRawRC(FIFODataReg);
//					printf (".%02X ",pOut[i]);
				}
			}
		}
		else {
			//			fprintf (stderr,"Err %02x\n",PcdErr);
			status = TAG_ERR;}

		if (PcdErr&0x08) {
			if (debug) fprintf (stderr,"COllision \n");
			status = TAG_COLLISION;

		}

	}


	//    SetBitMask(ControlReg,0x80);           // stop timer now
	//    WriteRawRC(CommandReg,PCD_IDLE); ???????
//	printf ("PCD Err %02x\n",PcdErr);
	return status;
}
Beispiel #16
0
status_t
DirEntryTree::InsertEntry(const char* name, uint64 blockIndex,
	Transaction& transaction)
{
	FUNCTION("name: \"%s\", blockIndex: %" B_PRIu64 "\n", name, blockIndex);

	status_t error = _InitWritable(transaction);
	if (error != B_OK)
		RETURN_ERROR(error);

	size_t nameLength = strlen(name);
	if (nameLength == 0)
		RETURN_ERROR(B_BAD_VALUE);
	if (nameLength > kCheckSumFSNameLength)
		RETURN_ERROR(B_NAME_TOO_LONG);

	int32 depth = _Depth();

	LevelInfo* infos = new(std::nothrow) LevelInfo[
		kCheckSumFSMaxDirEntryTreeDepth + 1];
	if (infos == NULL)
		RETURN_ERROR(B_NO_MEMORY);
	ArrayDeleter<LevelInfo> infosDeleter(infos);

	infos[0].entryBlock.SetTo(fRootEntryBlock, fRootEntryBlockSize);

	for (int32 level = 0; level <= depth; level++) {
		LevelInfo& info = infos[level];

		if (info.entryBlock.EntryCount() == 0) {
			if (level == 0) {
				PRINT("  directory is empty\n");
				// directory is empty
				info.index = 0;
				break;
			}

			RETURN_ERROR(B_BAD_DATA);
		}

		info.index = info.entryBlock.FindInsertionIndex(name, nameLength,
			info.exactMatch);

		PRINT("  level %" B_PRId32 ", block %" B_PRIu64 " -> index: %" B_PRId32
			" %sexact\n", level,
			level == 0 ? fDirectory->BlockIndex() : info.block.Index(),
			info.index, info.exactMatch ? "" : " not ");

		// Finding an exact match -- even in the non-final level -- means
		// that there's an entry with that name.
		if (info.exactMatch)
			RETURN_ERROR(B_FILE_EXISTS);

		if (level == depth) {
			// final level -- here we need to insert the entry
			break;
		}

		// Since we haven't found an exact match, the index points to the
		// first entry that is greater or after the last entry.
		info.index--;

		uint64 nextBlockIndex = info.entryBlock.BlockIndexAt(info.index);

		// not the final level -- load the block and descend to the next
		// level
		LevelInfo& nextInfo = infos[level + 1];
		if (!nextInfo.block.GetReadable(fDirectory->GetVolume(),
				nextBlockIndex)) {
			RETURN_ERROR(B_ERROR);
		}

		nextInfo.entryBlock.SetTo(
			(checksumfs_dir_entry_block*)nextInfo.block.Data(),
			B_PAGE_SIZE);
ASSERT(nextInfo.entryBlock.Check());
	}

	// We've found the insertion point. Insert the key and iterate backwards
	// to perform the potentially necessary updates. Insertion at index 0 of
	// the block changes the block's key, requiring an update in the parent
	// block. Insertion or key update can cause the block to be split (if
	// there's not enough space left in it), requiring an insertion in the
	// parent block. So we start with a pending insertion in the leaf block
	// and work our way upwards, performing key updates and insertions as
	// necessary.

	return _UpdateOrInsertKey(infos, depth, name, nameLength, blockIndex, true,
		transaction);
}
Beispiel #17
0
void PcdAntennaOff(void)
{
	FUNCTION() ;
	ClearBitMask(TxControlReg, 0x03);
}
Beispiel #18
0
status_t
DirEntryTree::RemoveEntry(const char* name, Transaction& transaction)
{
	FUNCTION("name: \"%s\"\n", name);

	status_t error = _InitWritable(transaction);
	if (error != B_OK)
		RETURN_ERROR(error);

	size_t nameLength = strlen(name);
	if (nameLength == 0)
		RETURN_ERROR(B_BAD_VALUE);
	if (nameLength > kCheckSumFSNameLength)
		RETURN_ERROR(B_ENTRY_NOT_FOUND);

	int32 depth = _Depth();

	LevelInfo* infos = new(std::nothrow) LevelInfo[
		kCheckSumFSMaxDirEntryTreeDepth + 1];
	if (infos == NULL)
		RETURN_ERROR(B_NO_MEMORY);
	ArrayDeleter<LevelInfo> infosDeleter(infos);

	infos[0].entryBlock.SetTo(fRootEntryBlock, fRootEntryBlockSize);

	for (int32 level = 0; level <= depth; level++) {
		LevelInfo& info = infos[level];

		if (info.entryBlock.EntryCount() == 0) {
			if (level == 0) {
				// directory is empty
				PRINT("  directory is empty\n");
				RETURN_ERROR(B_ENTRY_NOT_FOUND);
			}

			RETURN_ERROR(B_BAD_DATA);
		}

		info.index = info.entryBlock.FindInsertionIndex(name, nameLength,
			info.exactMatch);

		PRINT("  level %" B_PRId32 ", block %" B_PRIu64 " -> index: %" B_PRId32
			" %sexact\n", level,
			level == 0 ? fDirectory->BlockIndex() : info.block.Index(),
			info.index, info.exactMatch ? "" : " not ");

		if (level == depth) {
			// final level -- here the entry should be found
			if (!info.exactMatch)
				RETURN_ERROR(B_ENTRY_NOT_FOUND);
			break;
		}

		// If we haven't found an exact match, the index points to the first
		// entry that is greater or after the last entry.
		if (!info.exactMatch) {
			if (info.index == 0) {
				// The first entry is already greater, so the branch doesn't
				// contain the entry we're looking for.
				RETURN_ERROR(B_ENTRY_NOT_FOUND);
			}

			info.index--;
		}

		uint64 nextBlockIndex = info.entryBlock.BlockIndexAt(info.index);

		// not the final level -- load the block and descend to the next
		// level
		LevelInfo& nextInfo = infos[level + 1];
		if (!nextInfo.block.GetReadable(fDirectory->GetVolume(),
				nextBlockIndex)) {
			RETURN_ERROR(B_ERROR);
		}

		nextInfo.entryBlock.SetTo(
			(checksumfs_dir_entry_block*)nextInfo.block.Data(),
			B_PAGE_SIZE);
ASSERT(nextInfo.entryBlock.Check());
	}

	// We've found the entry. Insert the key and iterate backwards to perform
	// the potentially necessary updates. Removal at index 0 of the block
	// changes the block's key, requiring an update in the parent block.
	// Removal of the last entry will require removal of the block from its
	// parent. Key update can cause the block to be split (if there's not
	// enough space left in it), requiring an insertion in the parent block.
	// We start with a pending removal in the leaf block and work our way
	// upwards as long as the blocks become empty. As soon as a key update is
	// required, we delegate the remaining to the update/insert backwards loop.

	for (int32 level = depth; level >= 0; level--) {
		LevelInfo& info = infos[level];

		// make the block writable
		if (level > 0) {
			error = info.block.MakeWritable(transaction);
			if (error != B_OK)
				RETURN_ERROR(error);
		}

		PRINT("  level: %" B_PRId32 ", index: %" B_PRId32 ": removing key "
			"\"%.*s\" (%" B_PRIuSIZE ")\n", level, info.index, (int)nameLength,
			name, nameLength);

		if (info.entryBlock.EntryCount() == 1) {
			// That's the last key in the block. Unless that's the root level,
			// we remove the block completely.
			PRINT("  -> block is empty\n");
			if (level == 0) {
				info.entryBlock.RemoveEntry(info.index);
				return B_OK;
			}

			error = fDirectory->GetVolume()->GetBlockAllocator()->Free(
				info.block.Index(), 1, transaction);
			if (error != B_OK)
				RETURN_ERROR(error);
			fDirectory->SetSize(fDirectory->Size() - B_PAGE_SIZE);

			// remove the key (the same one) from the parent block
			continue;
		}

		// There are more entries, so just remove the entry in question. If it
		// is not the first one, we're done, otherwise we have to update the
		// block's key in the parent block.
		info.entryBlock.RemoveEntry(info.index);

		if (info.index > 0 || level == 0)
			return B_OK;

		name = info.entryBlock.NameAt(0, nameLength);
		return _UpdateOrInsertKey(infos, level - 1, name, nameLength, 0, false,
			transaction);
	}

	return B_OK;
}
Beispiel #19
0
FileWindow::FileWindow(std::string path) : Motif::Window("fileWindow")
{
  ini.reset(new OpenCDE::Ini(OpenCDE::Environment::getHome() + "/.opencde/dtfile/filetypes.ini"));
  setTitle("File Manager - /some/path");
  setIconName("path");
  setIconPixmap(OpenCDE::Environment::getPrefix() + "/share/opencde/pixmaps/Fphome.l.pm");
  setWidth(450);
  setHeight(350);
  setCloseFunction(FUNCTION(FileWindow::onClose));

  menuBar.reset(new Motif::MenuBar("menuBar", getContentPanel()));
  menuBar->setLeftAttachment(Motif::Attachment::FORM);
  menuBar->setRightAttachment(Motif::Attachment::FORM);
  menuBar->setTopAttachment(Motif::Attachment::FORM);
  filePulldownMenu.reset(new Motif::PulldownMenu("filePulldownMenu", menuBar.get()));
  filePulldownMenu->setText("File");
  newFolderButton.reset(new Motif::Button("newFolderButton", filePulldownMenu.get()));
  newFolderButton->setText("New Folder");
  newFileButton.reset(new Motif::Button("newFileButton", filePulldownMenu.get()));
  newFileButton->setText("New File");
  separators.add(new Motif::Separator("separator", filePulldownMenu.get()));
  instanceButton.reset(new Motif::Button("instanceButton", filePulldownMenu.get()));
  instanceButton->setText("New Window");
  instanceButton->setAccelerator("Ctrl<Key>w");
  instanceButton->setAcceleratorText("Ctrl+W");
  instanceButton->setActivateFunction(FUNCTION(FileWindow::onInstanceButtonClicked));
  terminalButton.reset(new Motif::Button("terminalButton", filePulldownMenu.get()));
  terminalButton->setText("Open Terminal");
  terminalButton->setAccelerator("Ctrl<Key>t");
  terminalButton->setAcceleratorText("Ctrl+T");
  terminalButton->setActivateFunction(FUNCTION(FileWindow::onTerminalButtonClicked));
  separators.add(new Motif::Separator("separator", filePulldownMenu.get()));
  closeButton.reset(new Motif::Button("closeButton", filePulldownMenu.get()));
  closeButton->setText("Close");
  closeButton->setActivateFunction(FUNCTION(FileWindow::onClose));
  //closeButton->setAccelerator("Alt<Key>f4");
  closeButton->setAcceleratorText("Alt+F4");
  //closeButton->setSensitive(false);
  selectedPulldownMenu.reset(new Motif::PulldownMenu("editPulldownMenu", menuBar.get()));
  selectedPulldownMenu->setText("Selected");
  viewPulldownMenu.reset(new Motif::PulldownMenu("optionsPulldownMenu", menuBar.get()));
  viewPulldownMenu->setText("View");
  helpPulldownMenu.reset(new Motif::PulldownMenu("helpPulldownMenu", menuBar.get()));
  helpPulldownMenu->setText("Help");
  menuBar->setHelpMenu(helpPulldownMenu.get());
  helpButton.reset(new Motif::Button("helpButton", helpPulldownMenu.get()));
  helpButton->setText("File Manager Help");
  //helpButton->setActivateFunction(FUNCTION(FileWindow::onClose));
  separators.add(new Motif::Separator("separator", helpPulldownMenu.get()));
  aboutButton.reset(new Motif::Button("aboutButton", helpPulldownMenu.get()));
  aboutButton->setText("About File Manager");
  //aboutButton->setActivateFunction(FUNCTION(FileWindow::onClose));

  statusPanel.reset(new Motif::Panel("statusPanel", getContentPanel()));
  statusPanel->setLeftAttachment(Motif::Attachment::FORM);
  statusPanel->setRightAttachment(Motif::Attachment::FORM);
  statusPanel->setBottomAttachment(Motif::Attachment::FORM);
  statusPanel->setHeight(25);
  statusPanel->setShadowThickness(1);

  mainPanel.reset(new Motif::Panel("mainPanel", getContentPanel()));
  mainPanel->setLeftAttachment(Motif::Attachment::FORM);
  mainPanel->setRightAttachment(Motif::Attachment::FORM);
  mainPanel->setTopAttachment(Motif::Attachment::WIDGET);
  mainPanel->setBottomAttachment(Motif::Attachment::WIDGET);
  mainPanel->setLeftOffset(0);
  mainPanel->setRightOffset(0);
  mainPanel->setTopWidget(menuBar.get());
  mainPanel->setBottomWidget(statusPanel.get());
  mainPanel->setShadowThickness(1);

  filePanel.reset(new Motif::Panel("filePanel", mainPanel.get()));
  filePanel->setLeftAttachment(Motif::Attachment::FORM);
  filePanel->setLeftOffset(5);
  filePanel->setRightAttachment(Motif::Attachment::FORM);
  filePanel->setRightOffset(25);
  filePanel->setTopAttachment(Motif::Attachment::FORM);
  filePanel->setTopOffset(5);
  filePanel->setBottomAttachment(Motif::Attachment::FORM);
  filePanel->setBottomOffset(5);
  filePanel->setShadowThickness(2);
  filePanel->setShadowType(Motif::ShadowType::IN);

  statusLabel.reset(new Motif::Label("statusLabel", statusPanel.get()));
  statusLabel->setTopAttachment(Motif::Attachment::FORM);
  statusLabel->setTopOffset(1);
  statusLabel->setBottomAttachment(Motif::Attachment::FORM);
  statusLabel->setBottomOffset(1);
  statusLabel->setLeftAttachment(Motif::Attachment::FORM);
  statusLabel->setLeftOffset(1);
  statusLabel->setText("99 Items 99 Hidden");

  fileScroll.reset(new Motif::ScrollBar("fileScroll", mainPanel.get()));
  fileScroll->setTopAttachment(Motif::Attachment::FORM);
  fileScroll->setTopOffset(5);
  fileScroll->setBottomAttachment(Motif::Attachment::FORM);
  fileScroll->setBottomOffset(5);
  fileScroll->setRightAttachment(Motif::Attachment::FORM);
  fileScroll->setRightOffset(5);
  fileScroll->setLeftAttachment(Motif::Attachment::NONE);
  fileScroll->setWidth(18);
  fileScroll->setMaximum(15);
  fileScroll->setDragFunction(FUNCTION(FileWindow::onScroll));
  fileScroll->setValueChangedFunction(FUNCTION(FileWindow::onScroll));

  fileView.reset(new FileView("fileView", filePanel.get(), fileScroll.get(), ini.get(), this));
  fileView->setTopAttachment(Motif::Attachment::FORM);
  fileView->setBottomAttachment(Motif::Attachment::FORM);
  fileView->setLeftAttachment(Motif::Attachment::FORM);
  fileView->setRightAttachment(Motif::Attachment::FORM);
  fileView->setTopOffset(2);
  fileView->setBottomOffset(2);
  fileView->setLeftOffset(2);
  fileView->setRightOffset(2);
  fileView->setPath(path);

  setVisible(true);
}
Beispiel #20
0
int
FUNCTION(gsl_fft_real,radix2_transform) (BASE data[], const size_t stride,  const size_t n)
{
  int result ;
  size_t p, p_1, q;
  size_t i; 
  size_t logn = 0;
  int status;

  if (n == 1) /* identity operation */
    {
      return 0 ;
    }

  /* make sure that n is a power of 2 */

  result = fft_binary_logn(n) ;

  if (result == -1) 
    {
      GSL_ERROR ("n is not a power of 2", GSL_EINVAL);
    } 
  else 
    {
      logn = result ;
    }

  /* bit reverse the ordering of input data for decimation in time algorithm */
  
  status = FUNCTION(fft_real,bitreverse_order)(data, stride, n, logn) ;

  /* apply fft recursion */

  p = 1; q = n ;

  for (i = 1; i <= logn; i++)
    {
      size_t a, b;

      p_1 = p ;
      p = 2 * p ;
      q = q / 2 ;

      /* a = 0 */

      for (b = 0; b < q; b++)
        {
          ATOMIC t0_real = VECTOR(data,stride,b*p) + VECTOR(data,stride,b*p + p_1) ;
          ATOMIC t1_real = VECTOR(data,stride,b*p) - VECTOR(data,stride,b*p + p_1) ;
          
          VECTOR(data,stride,b*p) = t0_real ;
          VECTOR(data,stride,b*p + p_1) = t1_real ;
        }

      /* a = 1 ... p_{i-1}/2 - 1 */

      {
        ATOMIC w_real = 1.0;
        ATOMIC w_imag = 0.0;

        const double theta = - 2.0 * M_PI / p;
        
        const ATOMIC s = sin (theta);
        const ATOMIC t = sin (theta / 2.0);
        const ATOMIC s2 = 2.0 * t * t;
        
        for (a = 1; a < (p_1)/2; a++)
          {
            /* trignometric recurrence for w-> exp(i theta) w */
            
            {
              const ATOMIC tmp_real = w_real - s * w_imag - s2 * w_real;
              const ATOMIC tmp_imag = w_imag + s * w_real - s2 * w_imag;
              w_real = tmp_real;
              w_imag = tmp_imag;
            }
            
            for (b = 0; b < q; b++)
              {
                ATOMIC z0_real = VECTOR(data,stride,b*p + a) ;
                ATOMIC z0_imag = VECTOR(data,stride,b*p + p_1 - a) ;
                ATOMIC z1_real = VECTOR(data,stride,b*p + p_1 + a) ;
                ATOMIC z1_imag = VECTOR(data,stride,b*p + p - a) ;
                
                /* t0 = z0 + w * z1 */
                
                ATOMIC t0_real = z0_real + w_real * z1_real - w_imag * z1_imag;
                ATOMIC t0_imag = z0_imag + w_real * z1_imag + w_imag * z1_real;
                
                /* t1 = z0 - w * z1 */
                
                ATOMIC t1_real = z0_real - w_real * z1_real + w_imag * z1_imag;
                ATOMIC t1_imag = z0_imag - w_real * z1_imag - w_imag * z1_real;
                
                VECTOR(data,stride,b*p + a) = t0_real ;
                VECTOR(data,stride,b*p + p - a) = t0_imag ;
                
                VECTOR(data,stride,b*p + p_1 - a) = t1_real ;
                VECTOR(data,stride,b*p + p_1 + a) = -t1_imag ;
              }
          }
      }

      if (p_1 >  1) 
        {
          for (b = 0; b < q; b++) 
            {
              /* a = p_{i-1}/2 */
              
              VECTOR(data,stride,b*p + p - p_1/2) *= -1 ;
            }
        }
    }
  return 0;
}
void
FUNCTION (test, func) (size_t stride, size_t N)
{
  TYPE (gsl_vector) * v0;
  TYPE (gsl_vector) * v;
  QUALIFIED_VIEW(gsl_vector,view) view;

  size_t i, j;

  if (stride == 1) 
    {
      v = FUNCTION (gsl_vector, calloc) (N);
      
      TEST(v->data == 0, "_calloc pointer");
      TEST(v->size != N, "_calloc size");
      TEST(v->stride != 1, "_calloc stride");

      {
        int status = (FUNCTION(gsl_vector,isnull)(v) != 1);
        TEST (status, "_isnull" DESC " on calloc vector");
      }

      FUNCTION (gsl_vector, free) (v);      /* free whatever is in v */
    }

  if (stride == 1) 
    {
      v = FUNCTION (gsl_vector, alloc) (N);
      
      TEST(v->data == 0, "_alloc pointer");
      TEST(v->size != N, "_alloc size");
      TEST(v->stride != 1, "_alloc stride");

      FUNCTION (gsl_vector, free) (v);      /* free whatever is in v */
    }

  if (stride == 1)
    {
      v0 = FUNCTION (gsl_vector, alloc) (N);
      view = FUNCTION (gsl_vector, subvector) (v0, 0, N);
      v = &view.vector;
    }
  else
    {
      v0 = FUNCTION (gsl_vector, alloc) (N * stride);

      for (i = 0; i < N*stride; i++)
        {
          BASE x = ZERO;
          GSL_REAL (x) = (ATOMIC)i;
          GSL_IMAG (x) = (ATOMIC)(i + 1234);
          FUNCTION (gsl_vector, set) (v0, i, x);
        }
      
      view = FUNCTION (gsl_vector, subvector_with_stride) (v0, 0, stride, N);
      v = &view.vector;
    }
      
  {
    int status = 0;

    for (i = 0; i < N; i++)
      {
        BASE x = ZERO;
        GSL_REAL (x) = (ATOMIC)i;
        GSL_IMAG (x) = (ATOMIC)(i + 1234);
        FUNCTION (gsl_vector, set) (v, i, x);
      }

    for (i = 0; i < N; i++)
      {
        if (v->data[2*i*stride] != (ATOMIC) (i) || v->data[2 * i * stride + 1] != (ATOMIC) (i + 1234))
          status = 1;
      };
  
    TEST(status,"_set" DESC " writes into array");
  }


  {
    int status = 0;

    for (i = 0; i < N; i++)
      {
        BASE x, y;
        GSL_REAL (x) = (ATOMIC)i;
        GSL_IMAG (x) = (ATOMIC)(i + 1234);
        y = FUNCTION (gsl_vector, get) (v, i);
        if (!GSL_COMPLEX_EQ (x, y))
          status = 1;
      };

    TEST (status, "_get" DESC " reads from array");
  }
  
  {
    int status = 0;

    for (i = 0; i < N; i++)
      {
        if (FUNCTION (gsl_vector, ptr) (v, i) != (BASE *)v->data + i*stride)
          status = 1;
      };

    TEST (status, "_ptr" DESC " access to array");
  }


  {
    int status = 0;
    
    for (i = 0; i < N; i++)
      {
        if (FUNCTION (gsl_vector, const_ptr) (v, i) != (BASE *)v->data + i*stride)
          status = 1;
      };
    
    TEST (status, "_const_ptr" DESC " access to array");
  }
  
  {
    int status = 0;
    
    for (i = 0; i < N; i++)
      {
        BASE x = ZERO;
        FUNCTION (gsl_vector, set) (v, i, x);
      }
    
    status = (FUNCTION(gsl_vector,isnull)(v) != 1);
    TEST (status, "_isnull" DESC " on null vector") ;
  }

  {
    int status = 0;

    for (i = 0; i < N; i++)
      {
        BASE x = ZERO;
        GSL_REAL (x) = (ATOMIC)i;
        GSL_IMAG (x) = (ATOMIC)(i + 1234);
        FUNCTION (gsl_vector, set) (v, i, x);
      }
    
    status = (FUNCTION(gsl_vector,isnull)(v) != 0);
    TEST (status, "_isnull" DESC " on non-null vector") ;
  }

  {
    int status = 0;
    
    FUNCTION (gsl_vector, set_zero) (v);

    for (i = 0; i < N; i++)
      {
        BASE x, y = ZERO;
        x = FUNCTION (gsl_vector, get) (v, i);
        if (!GSL_COMPLEX_EQ (x, y))
          status = 1;
      };

    TEST (status, "_setzero" DESC " on non-null vector") ;
  }

  {
    int status = 0;

    BASE x;
    GSL_REAL (x) = (ATOMIC)27;
    GSL_IMAG (x) = (ATOMIC)(27 + 1234);

    FUNCTION (gsl_vector, set_all) (v, x);

    for (i = 0; i < N; i++)
      {
        BASE y = FUNCTION (gsl_vector, get) (v, i);
        if (!GSL_COMPLEX_EQ (x, y))
          status = 1;
      };

    TEST (status, "_setall" DESC " to non-zero value") ;
  }


  {
    int status = 0;

    for (i = 0; i < N; i++)
      {
        FUNCTION (gsl_vector, set_basis) (v, i);

        for (j = 0; j < N; j++)
          {
            BASE x = FUNCTION (gsl_vector, get) (v, j);
            BASE one = ONE;
            BASE zero = ZERO;
              
            if (i == j)
              {
                if (!GSL_COMPLEX_EQ (x, one))
                  status = 1 ;
              }
            else 
              {
                if (!GSL_COMPLEX_EQ (x, zero))
                  status = 1;
              }
          };
      }

    TEST (status, "_setbasis" DESC " over range") ;
  }

  for (i = 0; i < N; i++)
    {
      BASE x = ZERO;
      GSL_REAL (x) = (ATOMIC)i;
      GSL_IMAG (x) = (ATOMIC)(i + 1234);
      FUNCTION (gsl_vector, set) (v, i, x);
    }

  {
    int status;
    BASE x, y, r, s ;
    GSL_REAL(x) = 2 ;
    GSL_IMAG(x) = 2 + 1234;
    GSL_REAL(y) = 5 ;
    GSL_IMAG(y) = 5 + 1234;

    FUNCTION (gsl_vector,swap_elements) (v, 2, 5) ;
    
    r = FUNCTION(gsl_vector,get)(v,2);
    s = FUNCTION(gsl_vector,get)(v,5);

    status = ! GSL_COMPLEX_EQ(r,y) ;
    status |= ! GSL_COMPLEX_EQ(s,x) ;
    
    FUNCTION (gsl_vector,swap_elements) (v, 2, 5) ;
    
    r = FUNCTION(gsl_vector,get)(v,2);
    s = FUNCTION(gsl_vector,get)(v,5);

    status |= ! GSL_COMPLEX_EQ(r,x) ;
    status |= ! GSL_COMPLEX_EQ(s,y) ;
  
    TEST (status, "_swap_elements" DESC " exchanges elements") ;
  }

  { 
    int status = 0;
    
    FUNCTION (gsl_vector,reverse) (v) ;
    
    for (i = 0; i < N; i++)
      {
        BASE x,r ;
        GSL_REAL(x) = (ATOMIC)(N - i - 1) ;
        GSL_IMAG(x) = (ATOMIC)(N - i - 1 + 1234);
        
        r = FUNCTION (gsl_vector, get) (v, i);
        
        status |= !GSL_COMPLEX_EQ(r,x);
      }
    
    gsl_test (status, NAME(gsl_vector) "_reverse" DESC " reverses elements") ;
  }
    
  {
    int status = 0;
    
    QUALIFIED_VIEW(gsl_vector,view) v1 = FUNCTION(gsl_vector, view_array) (v->data, N*stride);
    
    for (i = 0; i < N; i++)
      {
        BASE x = FUNCTION (gsl_vector, get) (&v1.vector, i*stride) ;
        BASE y = FUNCTION (gsl_vector, get) (v, i);
        if (!GSL_COMPLEX_EQ(x,y)) 
          status = 1;
      };

    TEST (status, "_view_array" DESC);
  }

  {
    int status = 0;
    
    QUALIFIED_VIEW(gsl_vector,view) v1 = FUNCTION(gsl_vector, view_array_with_stride) (v->data, stride, N*stride);
    
    for (i = 0; i < N; i++)
      {
        BASE x = FUNCTION (gsl_vector, get) (&v1.vector, i) ;
        BASE y = FUNCTION (gsl_vector, get) (v, i);
        if (!GSL_COMPLEX_EQ(x,y)) 
          status = 1;
      };

    TEST (status, "_view_array_with_stride" DESC);
  }


  {
    int status = 0;
    
    QUALIFIED_VIEW(gsl_vector,view) v1 = FUNCTION(gsl_vector, subvector) (v, N/3, N/2);
    
    for (i = 0; i < N/2; i++)
      {
        BASE x = FUNCTION (gsl_vector, get) (&v1.vector, i) ;
        BASE y = FUNCTION (gsl_vector, get) (v, (N/3)+i);
        if (!GSL_COMPLEX_EQ(x,y)) 
          status = 1;
      };

    TEST (status, "_view_subvector" DESC);
  }

  {
    int status = 0;
    
    QUALIFIED_VIEW(gsl_vector,view) v1 = FUNCTION(gsl_vector, subvector_with_stride) (v, N/5, 3, N/4);
    
    for (i = 0; i < N/4; i++)
      {
        BASE x = FUNCTION (gsl_vector, get) (&v1.vector, i) ;
        BASE y = FUNCTION (gsl_vector, get) (v, (N/5)+3*i);
        if (!GSL_COMPLEX_EQ(x,y)) 
          status = 1;
      };

    TEST (status, "_view_subvector_with_stride" DESC);
  }


  {
    int status = 0;
    
    QUALIFIED_REAL_VIEW(gsl_vector,view) vv = FUNCTION(gsl_vector, real) (v);
    
    for (i = 0; i < N; i++)
      {
        ATOMIC xr = REAL_VIEW (gsl_vector, get) (&vv.vector, i) ;
        BASE y = FUNCTION (gsl_vector, get) (v, i);
        ATOMIC yr = GSL_REAL(y);

        if (xr != yr) 
          status = 1;
      };

    TEST (status, "_real" DESC);
  }

  {
    int status = 0;
    
    QUALIFIED_REAL_VIEW(gsl_vector,view) vv = FUNCTION(gsl_vector, imag) (v);
    
    for (i = 0; i < N; i++)
      {
        ATOMIC xr = REAL_VIEW (gsl_vector, get) (&vv.vector, i) ;
        BASE y = FUNCTION (gsl_vector, get) (v, i);
        ATOMIC yr = GSL_IMAG(y);

        if (xr != yr) 
          status = 1;
      };

    TEST (status, "_imag" DESC);
  }


  FUNCTION (gsl_vector, free) (v0);      /* free whatever is in v */
}
Beispiel #22
0
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

int
FUNCTION(gsl_fft_complex,radix2_forward) (TYPE(gsl_complex_packed_array) data,
                                          const size_t stride, const size_t n)
{
  gsl_fft_direction sign = forward;
  int status = FUNCTION(gsl_fft_complex,radix2_transform) (data, stride, n, sign);
  return status;
}

int
FUNCTION(gsl_fft_complex,radix2_backward) (TYPE(gsl_complex_packed_array) data,
                                           const size_t stride, const size_t n)
{
  gsl_fft_direction sign = backward;
  int status = FUNCTION(gsl_fft_complex,radix2_transform) (data, stride, n, sign);
  return status;
}

int
FUNCTION(gsl_fft_complex,radix2_inverse) (TYPE(gsl_complex_packed_array) data,
                                          const size_t stride, const size_t n)
Beispiel #23
0
void
FUNCTION (test, ops) (const size_t M, const size_t N)
{
  size_t i, j;
  
  TYPE (gsl_matrix) * a = FUNCTION (gsl_matrix, calloc) (M, N);
  TYPE (gsl_matrix) * b = FUNCTION (gsl_matrix, calloc) (M, N);
  TYPE (gsl_matrix) * m = FUNCTION (gsl_matrix, alloc) (M, N);

  for (i = 0; i < M; i++)
    {
      for (j = 0; j < N; j++)
        {
          FUNCTION (gsl_matrix, set) (a, i, j, (BASE)(3 + i +  5 * j));
          FUNCTION (gsl_matrix, set) (b, i, j, (BASE)(3 + 2 * i + 4 * j));
        }
    }
  
  {
    int status = (FUNCTION(gsl_matrix,equal) (a,b) != 0);
    gsl_test (status, NAME (gsl_matrix) "_equal matrix unequal");
  }
  
  FUNCTION (gsl_matrix, memcpy) (m, a);
  
  {
    int status = (FUNCTION(gsl_matrix,equal) (a,m) != 1);
    gsl_test (status, NAME (gsl_matrix) "_equal matrix equal");
    }
  
  FUNCTION (gsl_matrix, add) (m, b);
    
  {
    int status = 0;
    
    for (i = 0; i < M; i++)
      {
        for (j = 0; j < N; j++)
          {
            BASE r = FUNCTION(gsl_matrix,get) (m,i,j);
            BASE x = FUNCTION(gsl_matrix,get) (a,i,j);
            BASE y = FUNCTION(gsl_matrix,get) (b,i,j);
            BASE z = x + y;
            if (r != z)
              status = 1;
          }
      }
    gsl_test (status, NAME (gsl_matrix) "_add matrix addition");
  }
  
  
  FUNCTION(gsl_matrix, memcpy) (m, a);
  FUNCTION(gsl_matrix, sub) (m, b);
  
  {
    int status = 0;
    
    for (i = 0; i < M; i++)
      {
        for (j = 0; j < N; j++)
          {
            BASE r = FUNCTION(gsl_matrix,get) (m,i,j);
            BASE x = FUNCTION(gsl_matrix,get) (a,i,j);
            BASE y = FUNCTION(gsl_matrix,get) (b,i,j);
            BASE z = x - y;
            if (r != z)
              status = 1;
          }
      }
    gsl_test (status, NAME (gsl_matrix) "_sub matrix subtraction");
  }
  
  FUNCTION(gsl_matrix, memcpy) (m, a);
  FUNCTION(gsl_matrix, mul_elements) (m, b);
  
  {
    int status = 0;
    
    for (i = 0; i < M; i++)
      {
        for (j = 0; j < N; j++)
          {
            BASE r = FUNCTION(gsl_matrix,get) (m,i,j);
            BASE x = FUNCTION(gsl_matrix,get) (a,i,j);
            BASE y = FUNCTION(gsl_matrix,get) (b,i,j);
            BASE z = x * y;
            if (r != z)
              status = 1;
          }
      }
    gsl_test (status, NAME (gsl_matrix) "_mul_elements multiplication");
  }

  FUNCTION(gsl_matrix, memcpy) (m, a);
  FUNCTION(gsl_matrix, div_elements) (m, b);
    
  {
    int status = 0;
      
    for (i = 0; i < M; i++)
      {
        for (j = 0; j < N; j++)
          {
            BASE r = FUNCTION(gsl_matrix,get) (m,i,j);
            BASE x = FUNCTION(gsl_matrix,get) (a,i,j);
            BASE y = FUNCTION(gsl_matrix,get) (b,i,j);
            BASE z = x / y;
            if (fabs(r - z) > 2 * GSL_FLT_EPSILON * fabs(z))
              status = 1;
          }
      }
    gsl_test (status, NAME (gsl_matrix) "_div_elements division");
  }


  FUNCTION(gsl_matrix, memcpy) (m, a);
  FUNCTION(gsl_matrix, scale) (m, 2.0);

  {
    int status = 0;

    for (i = 0; i < M; i++)
      {
        for (j = 0; j < N; j++)
          {
            BASE r = FUNCTION(gsl_matrix,get) (m,i,j);
            BASE x = FUNCTION(gsl_matrix,get) (a,i,j);
            if (r !=  (ATOMIC)(2*x))
              status = 1;
          }
      }
    gsl_test (status, NAME (gsl_matrix) "_scale");
  }

  FUNCTION(gsl_matrix, memcpy) (m, a);
  FUNCTION(gsl_matrix, add_constant) (m, 3.0);

  {
    int status = 0;

    for (i = 0; i < M; i++)
      {
        for (j = 0; j < N; j++)
          {
            BASE r = FUNCTION(gsl_matrix,get) (m,i,j);
            BASE x = FUNCTION(gsl_matrix,get) (a,i,j);
            BASE y = x + 3.0;
            if (fabs(r - y) > 2 * GSL_FLT_EPSILON * fabs(y))
              status = 1;
          }
      }
    gsl_test (status, NAME (gsl_matrix) "_add_constant");
  }

  FUNCTION(gsl_matrix, memcpy) (m, a);
  FUNCTION(gsl_matrix, add_diagonal) (m, 5.0);

  {
    int status = 0;

    for (i = 0; i < M; i++)
      {
        for (j = 0; j < N; j++)
          {
            BASE r = FUNCTION(gsl_matrix,get) (m,i,j);
            BASE x = FUNCTION(gsl_matrix,get) (a,i,j);
            BASE y = (i == j) ? (x + (ATOMIC) 5.0) : x;
            if (fabs(r - y) > 2 * GSL_FLT_EPSILON * fabs(y))
              status = 1;
          }
      }
    gsl_test (status, NAME (gsl_matrix) "_add_diagonal");
  }


  FUNCTION(gsl_matrix, swap) (a, b);

  {
    int status = 0;

    for (i = 0; i < M; i++)
      {
        for (j = 0; j < N; j++)
          {
            BASE x = FUNCTION(gsl_matrix,get) (a,i,j);
            BASE y = FUNCTION(gsl_matrix,get) (b,i,j);
            if (y != (BASE)(3 + i +  5 * j) || x != (BASE)(3 + 2 * i + 4 * j))
              status = 1;
          }
      }
    gsl_test (status, NAME (gsl_matrix) "_swap");
  }
      

  FUNCTION(gsl_matrix, free) (a);
  FUNCTION(gsl_matrix, free) (b);
  FUNCTION(gsl_matrix, free) (m);
}
Beispiel #24
0
void
FUNCTION (test, func) (const size_t stridea, const size_t strideb)
{
  /* sample sets of doubles */
  size_t i;
  const size_t na = 14, nb = 14;

  const double rawa[] =
  {.0421, .0941, .1064, .0242, .1331,
   .0773, .0243, .0815, .1186, .0356,
   .0728, .0999, .0614, .0479};

  const double rawb[] =
  {.1081, .0986, .1566, .1961, .1125,
   .1942, .1079, .1021, .1583, .1673,
   .1675, .1856, .1688, .1512};

  const double raww[] = 
  {.0000, .0000, .0000, 3.000, .0000,
   1.000, 1.000, 1.000, 0.000, .5000,
   7.000, 5.000, 4.000, 0.123};

  BASE * sorted ;

  BASE * groupa = (BASE *) malloc (stridea * na * sizeof(BASE));
  BASE * groupb = (BASE *) malloc (strideb * nb * sizeof(BASE));
  BASE * w = (BASE *) malloc (strideb * na * sizeof(BASE));

#ifdef BASE_FLOAT
  double rel = 1e-6;
#else
  double rel = 1e-10;
#endif

  for (i = 0 ; i < na ; i++)
    groupa[i * stridea] = (BASE) rawa[i] ;

  for (i = 0 ; i < na ; i++)
    w[i * strideb] = (BASE) raww[i] ;

  for (i = 0 ; i < nb ; i++)
    groupb[i * strideb] = (BASE) rawb[i] ;


  {
    double mean = FUNCTION(gsl_stats,mean) (groupa, stridea, na);
    double expected = 0.0728;
    gsl_test_rel (mean, expected, rel, NAME(gsl_stats) "_mean");
  }

  {
    double mean = FUNCTION(gsl_stats,mean) (groupa, stridea, na);
    double var = FUNCTION(gsl_stats,variance_with_fixed_mean) (groupa, stridea, na, mean);
    double expected = 0.00113837428571429;
    gsl_test_rel (var, expected, rel, NAME(gsl_stats) "_variance_with_fixed_mean");
  }


  {
    double mean = FUNCTION(gsl_stats,mean) (groupa, stridea, na);
    double var = FUNCTION(gsl_stats,sd_with_fixed_mean) (groupa, stridea, na, mean);
    double expected = 0.0337398026922845;
    gsl_test_rel (var, expected, rel, NAME(gsl_stats) "_sd_with_fixed_mean");
  }


  {
    double var = FUNCTION(gsl_stats,variance) (groupb, strideb, nb);
    double expected = 0.00124956615384615;
    gsl_test_rel (var, expected, rel, NAME(gsl_stats) "_variance");
  }

  {
    double sd = FUNCTION(gsl_stats,sd) (groupa, stridea, na);
    double expected = 0.0350134479659107;
    gsl_test_rel (sd, expected, rel, NAME(gsl_stats) "_sd");
  }

  {
    double absdev = FUNCTION(gsl_stats,absdev) (groupa, stridea, na);
    double expected = 0.0287571428571429;
    gsl_test_rel (absdev, expected, rel, NAME(gsl_stats) "_absdev");
  }

  {
    double skew = FUNCTION(gsl_stats,skew) (groupa, stridea, na);
    double expected = 0.0954642051479004;
    gsl_test_rel (skew, expected, rel, NAME(gsl_stats) "_skew");
  }

  {
    double kurt = FUNCTION(gsl_stats,kurtosis) (groupa, stridea, na);
    double expected = -1.38583851548909 ;
    gsl_test_rel (kurt, expected, rel, NAME(gsl_stats) "_kurtosis");
  }

  {
    double wmean = FUNCTION(gsl_stats,wmean) (w, strideb, groupa, stridea, na);
    double expected = 0.0678111523670601;
    gsl_test_rel (wmean, expected, rel, NAME(gsl_stats) "_wmean");
  }

  {
    double wmean = FUNCTION(gsl_stats,wmean) (w, strideb, groupa, stridea, na);
    double wvar = FUNCTION(gsl_stats,wvariance_with_fixed_mean) (w, strideb, groupa, stridea, na, wmean);
    double expected = 0.000615793060878654;
    gsl_test_rel (wvar, expected, rel, NAME(gsl_stats) "_wvariance_with_fixed_mean");
  }

  {
    double est_wvar = FUNCTION(gsl_stats,wvariance) (w, strideb, groupa, stridea, na);
    double expected = 0.000769562962860317;
    gsl_test_rel (est_wvar, expected, rel, NAME(gsl_stats) "_wvariance");
  }

  {
    double wsd = FUNCTION(gsl_stats,wsd) (w, strideb, groupa, stridea, na);
    double expected = 0.0277409978706664;
    gsl_test_rel (wsd, expected, rel, NAME(gsl_stats) "_wsd");
  }

  {
    double wabsdev = FUNCTION(gsl_stats,wabsdev) (w, strideb, groupa, stridea, na);
    double expected = 0.0193205027504008;
    gsl_test_rel (wabsdev, expected, rel, NAME(gsl_stats) "_wabsdev");
  }

  {
    double wskew = FUNCTION(gsl_stats,wskew) (w, strideb, groupa, stridea, na);
    double expected = -0.373631000307076;
    gsl_test_rel (wskew, expected, rel, NAME(gsl_stats) "_wskew");
  }

  {
    double wkurt = FUNCTION(gsl_stats,wkurtosis) (w, strideb, groupa, stridea, na);
    double expected = -1.48114233353963;
    gsl_test_rel (wkurt, expected, rel, NAME(gsl_stats) "_wkurtosis");
  }

  {
    double c = FUNCTION(gsl_stats,covariance) (groupa, stridea, groupb, strideb, nb);
    double expected = -0.000139021538461539;
    gsl_test_rel (c, expected, rel, NAME(gsl_stats) "_covariance");
  }


  {
    double pv = FUNCTION(gsl_stats,pvariance) (groupa, stridea, na, groupb, strideb, nb);
    double expected = 0.00123775384615385;
    gsl_test_rel (pv, expected, rel, NAME(gsl_stats) "_pvariance");
  }

  {
    double t = FUNCTION(gsl_stats,ttest) (groupa, stridea, na, groupb, strideb, nb);
    double expected = -5.67026326985851;
    gsl_test_rel (t, expected, rel, NAME(gsl_stats) "_ttest");
  }

  {
    BASE expected = (BASE)0.1331;
    gsl_test  (FUNCTION(gsl_stats,max) (groupa, stridea, na) != expected,
               NAME(gsl_stats) "_max (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", 
               FUNCTION(gsl_stats,max) (groupa, stridea, na), expected);
  }

  {
    BASE min = FUNCTION(gsl_stats,min) (groupa, stridea, na);
    BASE expected = (BASE)0.0242;
    gsl_test (min != expected,
              NAME(gsl_stats) "_min (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", 
              min, expected);
  }

  {
    BASE min, max;
    BASE expected_max = (BASE)0.1331;
    BASE expected_min = (BASE)0.0242;
    
    FUNCTION(gsl_stats,minmax) (&min, &max, groupa, stridea, na);
 
    gsl_test  (max != expected_max,
               NAME(gsl_stats) "_minmax max (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", 
               max, expected_max);
    gsl_test  (min != expected_min,
               NAME(gsl_stats) "_minmax min (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", 
               min, expected_min);
  }

  {
    int max_index = FUNCTION(gsl_stats,max_index) (groupa, stridea, na);
    int expected = 4;
    gsl_test (max_index != expected,
              NAME(gsl_stats) "_max_index (%d observed vs %d expected)",
              max_index, expected);
  }

  {
    int min_index = FUNCTION(gsl_stats,min_index) (groupa, stridea, na);
    int expected = 3;
    gsl_test (min_index != expected,
              NAME(gsl_stats) "_min_index (%d observed vs %d expected)",
              min_index, expected);
  }

  {
    size_t min_index, max_index;
    size_t expected_max_index = 4;
    size_t expected_min_index = 3;

    FUNCTION(gsl_stats,minmax_index) (&min_index, &max_index, groupa, stridea, na);

    gsl_test  (max_index != expected_max_index,
               NAME(gsl_stats) "_minmax_index max (%u observed vs %u expected)", 
               max_index, expected_max_index);
    gsl_test  (min_index != expected_min_index,
               NAME(gsl_stats) "_minmax_index min (%u observed vs %u expected)", 
               min_index, expected_min_index);
  }


  sorted = (BASE *) malloc(stridea * na * sizeof(BASE)) ;
  
  for (i = 0 ; i < na ; i++)
    sorted[stridea * i] = groupa[stridea * i] ;
  
  TYPE(gsl_sort)(sorted, stridea, na) ;

  {
    double median = FUNCTION(gsl_stats,median_from_sorted_data)(sorted, stridea, na) ;
    double expected = 0.07505;
    gsl_test_rel  (median,expected, rel,
                   NAME(gsl_stats) "_median_from_sorted_data (even)");
  }

  {
    double median = FUNCTION(gsl_stats,median_from_sorted_data)(sorted, stridea, na - 1) ;
    double expected = 0.0728;
    gsl_test_rel  (median,expected, rel,
                   NAME(gsl_stats) "_median_from_sorted_data");
  }


  {
    double zeroth = FUNCTION(gsl_stats,quantile_from_sorted_data)(sorted, stridea, na, 0.0) ;
    double expected = 0.0242;
    gsl_test_rel  (zeroth,expected, rel,
                   NAME(gsl_stats) "_quantile_from_sorted_data (0)");
  }

  {
    double top = FUNCTION(gsl_stats,quantile_from_sorted_data)(sorted, stridea, na, 1.0) ;
    double expected = 0.1331;
    gsl_test_rel  (top,expected, rel,
                   NAME(gsl_stats) "_quantile_from_sorted_data (100)");
  }

  {
    double median = FUNCTION(gsl_stats,quantile_from_sorted_data)(sorted, stridea, na, 0.5) ;
    double expected = 0.07505;
    gsl_test_rel  (median,expected, rel,
                   NAME(gsl_stats) "_quantile_from_sorted_data (50even)");
  }

  {
    double median = FUNCTION(gsl_stats,quantile_from_sorted_data)(sorted, stridea, na - 1, 0.5);
    double expected = 0.0728;
    gsl_test_rel  (median,expected, rel,
                   NAME(gsl_stats) "_quantile_from_sorted_data (50odd)");

  }

  free (sorted);
  free (groupa);
  free (groupb);
  free (w);
}
Beispiel #25
0
void
FUNCTION (test, trap) (const size_t M, const size_t N)
{
  TYPE (gsl_matrix) * m = FUNCTION (gsl_matrix, alloc) (M, N);

  size_t i = 0, j = 0;
  double x;

  status = 0;
  FUNCTION (gsl_matrix, set) (m, M + 1, 0, (BASE) 1.2);
  gsl_test (!status,
            NAME (gsl_matrix) "_set traps 1st index above upper bound");

  status = 0;
  FUNCTION (gsl_matrix, set) (m, 0, N + 1, (BASE) 1.2);
  gsl_test (!status,
            NAME (gsl_matrix) "_set traps 2nd index above upper bound");

  status = 0;
  FUNCTION (gsl_matrix, set) (m, M, 0, (BASE) 1.2);
  gsl_test (!status,
            NAME (gsl_matrix) "_set traps 1st index at upper bound");

  status = 0;
  FUNCTION (gsl_matrix, set) (m, 0, N, (BASE) 1.2);
  gsl_test (!status,
            NAME (gsl_matrix) "_set traps 2nd index at upper bound");

  status = 0;
  x = FUNCTION (gsl_matrix, get) (m, i - 1, 0);
  gsl_test (!status,
            NAME (gsl_matrix) "_get traps 1st index below lower bound");
  gsl_test (x != 0,
     NAME (gsl_matrix) "_get returns zero for 1st index below lower bound");

  status = 0;
  x = FUNCTION (gsl_matrix, get) (m, 0, j - 1);
  gsl_test (!status,
            NAME (gsl_matrix) "_get traps 2nd index below lower bound");
  gsl_test (x != 0,
     NAME (gsl_matrix) "_get returns zero for 2nd index below lower bound");

  status = 0;
  x = FUNCTION (gsl_matrix, get) (m, M + 1, 0);
  gsl_test (!status,
            NAME (gsl_matrix) "_get traps 1st index above upper bound");
  gsl_test (x != 0,
     NAME (gsl_matrix) "_get returns zero for 1st index above upper bound");

  status = 0;
  x = FUNCTION (gsl_matrix, get) (m, 0, N + 1);
  gsl_test (!status,
            NAME (gsl_matrix) "_get traps 2nd index above upper bound");
  gsl_test (x != 0,
     NAME (gsl_matrix) "_get returns zero for 2nd index above upper bound");

  status = 0;
  x = FUNCTION (gsl_matrix, get) (m, M, 0);
  gsl_test (!status,
            NAME (gsl_matrix) "_get traps 1st index at upper bound");
  gsl_test (x != 0,
        NAME (gsl_matrix) "_get returns zero for 1st index at upper bound");

  status = 0;
  x = FUNCTION (gsl_matrix, get) (m, 0, N);
  gsl_test (!status,
            NAME (gsl_matrix) "_get traps 2nd index at upper bound");
  gsl_test (x != 0,
        NAME (gsl_matrix) "_get returns zero for 2nd index at upper bound");

  FUNCTION (gsl_matrix, free) (m);
}
Beispiel #26
0
double 
FUNCTION(gsl_stats,variance_with_fixed_mean) (const BASE data[], const size_t stride, const size_t n, const double mean)
{
  const double variance = FUNCTION(compute,variance) (data, stride, n, mean);
  return variance;
}
Beispiel #27
0
void
TVideoPreviewView::DisplayThread()
{
	FUNCTION("TVideoPreviewView::DisplayThread\n");

	bigtime_t timeout = 5000;
	bigtime_t realTimeNow = 0;
	bigtime_t perfTimeNow = 0;
	bigtime_t halfPeriod = (bigtime_t) (500000./29.97);
	bool timeSourceRunning = false;

	while (!mDisplayQuit) {
		if (acquire_sem(mServiceLock) == B_NO_ERROR) {
			timeSourceRunning = TimeSource()->IsRunning();
			realTimeNow = BTimeSource::RealTime();
			perfTimeNow = TimeSource()->Now();
			release_sem(mServiceLock);
		}

		snooze(timeout);

		if (timeSourceRunning) {

			// if we received a Stop, deal with it
			if (mStopping) {
				PROGRESS("VidConsumer::DisplayThread - STOP\n");
				if (perfTimeNow >= mStopTime) {
					mRunning = false;
					mStopping = false;

					// deal with any pending Seek
					if (mSeeking)
						mSeeking = false;

					//if (mConnected)
					//	SendDataStatus(B_DATA_NOT_AVAILABLE, mConnections[0], mStopTime);

					continue;
				}
			}

			// if we received a Seek, deal with it
			if (mSeeking) {
				PROGRESS("VidConsumer::DisplayThread - SEEK\n");
				if (perfTimeNow >= mSeekTime) {
					PROGRESS("VidConsumer::DisplayThread - DO SEEK\n");
					mSeeking = false;
					mDeltaTime = mMediaTime;

					continue;
				}
			}

			// if we received a Start, deal with it
			if (mStarting) {
				PROGRESS("BBt848Controllable::CaptureRun mStartTime = %.4f TimeNow = %.4f\n", (double)mStartTime/M1, (double)perfTimeNow/M1);
				if (perfTimeNow >= mStartTime) {
					mRunning = true;
					mStarting = false;
					mDeltaTime = mStartTime;

					//if (mConnected)
					//	SendDataStatus(B_DATA_AVAILABLE, mConnections[0], mStartTime);

					continue;
				}
			}

			if (mRunning) {
				// check for buffer available.
				status_t err = acquire_sem_etc(mBufferAvailable, 1, B_TIMEOUT, halfPeriod * 2);

				if (err == B_TIMED_OUT || !mConnected) {
					ERROR("VidConsumer::DisplayThread - Error from acquire_sem_etc: 0x%lx\n", err);
					continue;
				}

				BBuffer* buffer = mBufferQueue->PopFirstBuffer(0);

				LOOP("Popped buffer %08x, Start time: %.4f, system time: %.4f diff: %.4f\n",
				     buffer,
				     (double) buffer->Header()->start_time/M1,
				     (double) perfTimeNow/M1,
				     (double) (buffer->Header()->start_time - perfTimeNow)/M1);

				// Display frame if we're in B_OFFLINE mode or
				// within +/- a half frame time of start time
				if ( (mRunMode == B_OFFLINE) ||
				     ((perfTimeNow > (buffer->Header()->start_time - halfPeriod)) &&
				      (perfTimeNow < (buffer->Header()->start_time + halfPeriod))) ) {
					uint32 bpp = (mColorspace == B_RGB32 ? 4 : 2);
					memcpy(m_Bitmap->Bits(), buffer->Data(), mRowBytes * mYSize * bpp);
					buffer->Header()->start_time = system_time();
					buffer->Recycle();
					bigtime_t t1 = system_time();

					//	Update view
					if (LockLooper()) {
						DrawBitmap(m_Bitmap, Bounds());
						UnlockLooper();
					}

					t1 = system_time() - t1;
					if (t1/M1 > .030)
						printf("Draw time = %.4f\n",t1/M1);
					continue;
				} else {
					// If we're too early, push frame back on stack
					if (perfTimeNow < buffer->Header()->start_time) {
						LOOP("push buffer back on stack!\n");
						mBufferQueue->PushBuffer(buffer, buffer->Header()->start_time);
						release_sem(mBufferAvailable);
						continue;
					} else {
						// if we've already passed a half frame time past the buffer start time
						// and RunMode = INCREASE_LATENCY, increase latency and display the frame
						if ( (perfTimeNow > buffer->Header()->start_time) &&
						     (mRunMode == B_INCREASE_LATENCY)) {
							mMyLatency += halfPeriod;
							ERROR("VidConsumer::DisplayThread - Increased latency to: %.4f\n", mMyLatency);
							ERROR("	 Performance time: %.4f @ %.4f\n", (double)buffer->Header()->start_time/M1, (double)perfTimeNow/M1);
							uint32 bpp = (mColorspace == B_RGB32 ? 4 : 2);
							memcpy(m_Bitmap->Bits(), buffer->Data(), mRowBytes * mYSize * bpp);
							buffer->Recycle();

							// should send late notice
							if (LockLooper()) {
								DrawBitmap(m_Bitmap, Bounds());
								UnlockLooper();
							}

							continue;
						} else {
							// we're more than a half frame time past the buffer start time
							// drop the frame
							ERROR("VidConsumer::DisplayThread - dropped late frame: %.4f @ %.4f\n", (double)buffer->Header()->start_time/M1, (double)perfTimeNow/M1);
							buffer->Recycle();
							// should send late notice
							continue;
						}
					}
				}
			}
			snooze(timeout);
		}  else snooze(timeout); // if TimeSource stopped
	} // while (!mTimeToQuit)
}
Beispiel #28
0
double 
FUNCTION(gsl_stats,variance) (const BASE data[], const size_t stride, const size_t n)
{
  const double mean = FUNCTION(gsl_stats,mean) (data, stride, n);
  return FUNCTION(gsl_stats,variance_m)(data, stride, n, mean);
}
Beispiel #29
0
static const char * const bxt_north_pwm1_groups[] = { "pwm1_grp" };
static const char * const bxt_north_pwm2_groups[] = { "pwm2_grp" };
static const char * const bxt_north_pwm3_groups[] = { "pwm3_grp" };
static const char * const bxt_north_uart0_groups[] = {
	"uart0_grp", "uart0b_grp",
};
static const char * const bxt_north_uart1_groups[] = {
	"uart1_grp", "uart1b_grp",
};
static const char * const bxt_north_uart2_groups[] = {
	"uart2_grp", "uart2b_grp",
};
static const char * const bxt_north_uart3_groups[] = { "uart3_grp" };

static const struct intel_function bxt_north_functions[] = {
	FUNCTION("pwm0", bxt_north_pwm0_groups),
	FUNCTION("pwm1", bxt_north_pwm1_groups),
	FUNCTION("pwm2", bxt_north_pwm2_groups),
	FUNCTION("pwm3", bxt_north_pwm3_groups),
	FUNCTION("uart0", bxt_north_uart0_groups),
	FUNCTION("uart1", bxt_north_uart1_groups),
	FUNCTION("uart2", bxt_north_uart2_groups),
	FUNCTION("uart3", bxt_north_uart3_groups),
};

static const struct intel_community bxt_north_communities[] = {
	BXT_COMMUNITY(0, 82),
};

static const struct intel_pinctrl_soc_data bxt_north_soc_data = {
	.uid = "1",
status_t
VideoConsumer::AcceptFormat(const media_destination& dest, media_format* format)
{
	FUNCTION("VideoConsumer::AcceptFormat\n");
	
	if (dest != fIn.destination) {
		ERROR("VideoConsumer::AcceptFormat - BAD DESTINATION\n");
		return B_MEDIA_BAD_DESTINATION;	
	}
	
	if (format->type == B_MEDIA_NO_TYPE)
		format->type = B_MEDIA_RAW_VIDEO;
	
	if (format->type != B_MEDIA_RAW_VIDEO) {
		ERROR("VideoConsumer::AcceptFormat - BAD FORMAT\n");
		return B_MEDIA_BAD_FORMAT;
	}

	if (format->u.raw_video.display.format
			!= media_raw_video_format::wildcard.display.format) {
		uint32 flags = 0;
		bool supported = bitmaps_support_space(
			format->u.raw_video.display.format, &flags);
#ifndef HAIKU_TARGET_PLATFORM_HAIKU
		// GRRR! BeOS implementation claims not
		// to support these formats, while they work just fine.
		switch (format->u.raw_video.display.format) {
			case B_YCbCr422:
			case B_YCbCr411:
			case B_YCbCr444:
			case B_YCbCr420:
				supported = true;
				break;
			default:
				break;
		}
#endif
		if (!supported) {
			// cannot create bitmaps with such a color space
			ERROR("AcceptFormat - unsupported color space for BBitmaps "
				"(%s)!\n",
				color_space_to_string(format->u.raw_video.display.format));
			return B_MEDIA_BAD_FORMAT;
		}
		if (!fTryOverlay && (flags & B_VIEWS_SUPPORT_DRAW_BITMAP) == 0) {
			// BViews do not support drawing such a bitmap
			ERROR("AcceptFormat - BViews cannot draw bitmaps in given "
				"colorspace (%s)!\n",
				color_space_to_string(format->u.raw_video.display.format));
			return B_MEDIA_BAD_FORMAT;
		}
	}

	#ifdef TRACE_VIDEO_CONSUMER
		char string[256];
		string[0] = 0;
		string_for_format(*format, string, 256);
		FUNCTION("VideoConsumer::AcceptFormat: %s\n", string);
	#endif

	return B_OK;
}